Assignemnt #12 and Variables And Names
Code
/// Name: Raff Lisbona
/// Period: 6
/// Program Name: Variables and Names
/// File Name: VariablesAndNames.java
/// Date Finished: 9/15/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;
//this replaces "cars" with "100".
cars = 100;
//space_in_a_car is replaced with "4".
space_in_a_car = 4;
//drivers is replaced with "30".
drivers = 30;
//passengers is replaced with "90".
passengers = 90;
//cars_not_driven will make the computer do the math "100-30".
cars_not_driven = cars - drivers;
//cars_driven will be replaced with the number for "drivers" which is 30.
cars_driven = drivers;
//this will multiply cars_driven by space_in_a_car
carpool_capacity = cars_driven * space_in_a_car;
//This will divide the number of passengers 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." );
}
}
Picture of the output