VariablesAndNames
Code
/// Name: Sam Benoy
/// Period: 6
/// Program Name:Variables and Names
/// File Name: VariablesAndNames.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;
//The number of cars
cars = 100;
//How much space is in the car
space_in_a_car = 4.0;
//How many drivers are available
drivers = 30;
//How many people have been in the car
passengers = 90;
//Cars minus the drivers equals cars not driven
cars_not_driven = cars - drivers;
//Cars driven equal drivers
cars_driven = drivers;
//Cars driven equals number of drivers
carpool_capacity = cars_driven * space_in_a_car;
//average passenger per car equal passenger divided by 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." );
}
}
VariablesAndNames