Assignemnt #12 and Variables And Names
Code
///Name: Daniel Tiffany-Appleton
///Period: 7
///Program Name:Variables And Names
///File Name: VariablesAndNames
///Date Finished: 9/14/15
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 number of cars=100
cars = 100;
//the number seats in a car is 4, and what will happen if the floating point, or the decimal and the zero, the calculation will be less accurate
space_in_a_car = 4.0;
//the number of drivers is 30
drivers = 30;
//the number of passangers is 90
passengers = 90;
//the number of cars not driven is equal 100-30
cars_not_driven = cars - drivers;
//the number of cars driven equal the the number of drivers
cars_driven = drivers;
//the carpool capacity equal to 30*4.0
carpool_capacity = cars_driven * space_in_a_car;
//the average number of passangers per car equal 90/30
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