Assignment #12 and Variables And Names
Code
/// Name: Graham Pollock
/// Period: 5
/// Program Name: Variables and Names
/// File Name: VariableAndNames.java
/// Date Finished: 9/11/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;
//100 is not a floating point number
cars = 100;
//4.0 is a Floating point
space_in_a_car = 4;
//IF It is just 4 there are no decimals or remainders and the math is wrong
drivers = 30;
//A Floating Point number means that there is no fixed number of digits before and after the decimal point
passengers = 90;
cars_not_driven = cars - drivers;
cars_driven = drivers;
carpool_capacity = cars_driven * space_in_a_car;
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