Assignemnt #12 and Variables and Numbers
Code
/// Name: Mark Katz
/// Period: 6
/// Program Name: Variables and Names
/// File Name: VariablesAndNames.java
/// Date Finished: 9/10/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;
//There are 100 cars
cars = 100;
//There can be 4 people per car
space_in_a_car = 4;
//There are 30 drivers
drivers = 30;
//There are 90 passengers
passengers = 90;
//The number of cars not driven is the number of cars minus the number of drivers
cars_not_driven = cars - drivers;
//The number of cars driven is the number of drivers
cars_driven = drivers;
//The capacity of the carpool is the number of cars driven times the number of space in the car
carpool_capacity = cars_driven * space_in_a_car;
//The average passengers per car is the number of passengers divided by the number of cars driven
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