Assignemnt #12
Code
/// Name: Colin Hinton
/// Period: 5
/// Project Name: VariablesAndNames
/// File Name: VariablesAndNames.java
/// Date Finished: 9/10/2015
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;
//number of cars is 100
cars= 100;
//space per car is 4
space_in_a_car= 4;
// there are 30 drivers
drivers= 30;
// there are 90 passangers
passengers = 90;
// equating number of unused cars
cars_not_driven = cars - drivers;
// the number of cars driven must be the number of drivers
cars_driven = drivers;
// number of space in cars for passengers
carpool_capacity = cars_driven * space_in_a_car;
// equating number f people per 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