Assignemnt #12 and Variables And Names
Code
///Name: Morgan Kaplan
///Period: 5
///Project Name: VariablesAndNames
///File Name: VariablesAndNames.java
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 variable cars equals 100
cars = 100;
//The variable space_in_a_car equals 4.0
space_in_a_car = 4.0;
//The variable drivers equals 30
drivers = 30;
//the variable passengers equals 90
passengers = 90;
// the variable cars_not_driven equals 100-30 which equals 70
cars_not_driven = cars - drivers;
// the variable cars_driven equals 30
cars_driven = drivers;
//the variables carpool_capacity equals 30 * 4.0 which equals 120
carpool_capacity = cars_driven * space_in_a_car;
// the variable average_passengers_per_car equals 90 / 30 which equals 3
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 Output