Assignment #12 and Variables And Names
Code
/// Name: Matthew Lorence
/// Period: 5
/// Program Name: VariablesAndNames
/// File Name: VariablesAndNames.java
/// Date Finished:9/16/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;
cars = 100;
/// 4 didn't make a difference compared to 4.0
space_in_a_car = 4;
drivers = 30;
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;
/// Prints out the text, but substitutes 100 for cars.
System.out.println( "There are " + cars + " cars available." );
/// Prints out the text, but substitutes 30 for drivers.
System.out.println( "There are only " + drivers + " drivers available." );
/// Prints out the text, but substitutes 100 for cars and 30 for drivers then substitutes those values into cars_not_driven.
System.out.println( "There will be " + cars_not_driven + " empty cars today." );
/// Prints out the text, but substitutes 30 for cars and cars_driven into cars. Then 30 is multiplied by 4 which is substituted into the space_in_a_car.
System.out.println( "We can transport " + carpool_capacity + " people today." );
/// Prints out the text, but substitutes 90 for passengers.
System.out.println( "We have " + passengers + " to carpool today." );
/// Prints out the text, but substitutes 90 for passengers and divides that by 30 for cars driven, which is the formula for average_passengers_per_car.
System.out.println( "We need to put about " + average_passengers_per_car + " in each car." );
}
}
Picture of the output