Assignment #12
Code
///Name: Cody Swain
///Period: 6
///Project Name: variablesAndNames
///File Name: VariablesAndNames.java
///Date: 9/14/15
public class VariablesAndNames
{
public static void main(String[] args )
{
// Below Line -Creates variables of the integer type, for the listed names.
int cars, drivers, passengers, cars_not_driven, cars_driven;
// Below Line -Doubles have decimal places
double space_in_a_car, carpool_capacity, average_passengers_per_car;
// Assigns the value of 100 to the integer variable car
cars = 100;
//Assigns the value of 4.0 to the double variable space_in_a_car
space_in_a_car = 4.0;
//Assigns the value of 30 to the integer variable driver
drivers = 30;
//Assigns the value of 90 to the integer variable passenger
passengers = 90;
//Assigns the value of [(value of drivers) subtracted from (value of cars)] to the integer variable c cars_not_driven
cars_not_driven = cars - drivers;
//Assigns the value of drivers (which is 30) to the integer variable cars_driven
cars_driven = drivers;
//Assigns the value of 30 * 4.0; to carpool_capacity
carpool_capacity = cars_driven * space_in_a_car;
//Assigns the value of 90 / 30 (which equals three) to average_passengers_per_car
average_passengers_per_car = passengers / cars_driven;
//What is displayed
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