View RSS Feed

spek

Multiple variables

Rate this Entry
by , 03-09-2012 at 11:44 PM (772 Views)
I'm just getting started with programming and i want it so that if the variable = 0 it doesn't show up in the equation. I made an alternate boolean variable but i need help with the rest or any other ideas


public class App {

public App() {
public static void main(String[] args) {


System.out.println("Skating");
float speed = 2;
boolean speed2;
if (speed >= 0){speed2 = true;
}else if (speed <= 0){speed2 = false;}
float technique = 3;
boolean technique2;
if (technique >= 0){technique2 = true;}
else if (technique <= 0){technique2 = false;}
float acceleration = 4;
int acceleration2;
if (acceleration >= 0){acceleration2 = 1;}
else if (acceleration <= 0){acceleration2 = 2;}
float backwards = 1;
int backwards2;
if (backwards >= 0){backwards2 = 1;}
else if (backwards <= 0){backwards2 =2;}
float average_skating = (backwards + acceleration + technique + speed)/4;
System.out.println("the average is "
+average_skating);
}}

Submit "Multiple variables" to Facebook Submit "Multiple variables" to Digg Submit "Multiple variables" to del.icio.us Submit "Multiple variables" to StumbleUpon Submit "Multiple variables" to Google

Categories
Uncategorized

Comments