Assignemnt #12 and Variables and Names
Code
/// Name: Tristan Chung
/// Period: 5
/// Program Name: VariablesAndNames
/// 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;
cars = 100;
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;
// This uses the variables for cars to equal 100
System.out.println( "There are " + cars + " cars available." );
// This uses the variable for drivers to equal 30.
System.out.println( "There are only " + drivers + " drivers available." );
// This uses the variable cars_not_driven to equal cars- drivers
System.out.println( "There will be " + cars_not_driven + " empty cars today." );
// This uses the variable carpool_capacity to display the result of cars_driven times space_in_a_car
System.out.println( "We can transport " + carpool_capacity + " people today." );
// This uses the variable passengers and displays 90.
System.out.println( "We have " + passengers + " to carpool today." );
// This lines uses the variable average_passengers_per_car to display the result of passengers / cars_driven
System.out.println( "We need to put about " + average_passengers_per_car + " in each car." );
}
}
Picture of the output