Assignemnt #12 Variables And Names
Code
/// Name: DeeJay Cerezo
/// Period: 7
/// Program Name: Variables And Names
/// File Name: VariablesAndNames.java
/// Date Finished: 9/14/2015
public class VariablesAndNames
{
public static void main( String[] args )
{
int cars, drivers, passengers, cars_not_driven, cars_driven;
double space_in_a_car, carpool_capacity, average_passengers_per_car;
// the = named the variable
cars = 100;
// Changing it to 4 didnt do anything.
space_in_a_car = 4.0;
drivers = 30;
passengers = 90;
// variable is the solution to the variables "car" minus "drivers"
cars_not_driven = cars - drivers;
// made the variable equal the same as the varisble for "drivers"
cars_driven = drivers;
//multiplied two variables
carpool_capacity = cars_driven * space_in_a_car;
//divided two variables
average_passengers_per_car = passengers / cars_driven;
System.out.println( "There are " + cars + " cars available." );
System.out.println( "There are only " + drivers + " drivers available." );
System.out.println( "There will be " + cars_not_driven + " empty cars today." );
System.out.println( "We can transport " + carpool_capacity + " people today." );
System.out.println( "We have " + passengers + " to carpool today." );
System.out.println( "We need to put about " + average_passengers_per_car + " in each car." );
}
}
Picture of the output