Assignemnt #12, Variables And Names
Code
/// Name: Carlos Sosa
/// Period: 6
/// Date: 9/29/15
/// Program 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;
/// Designates amount of cars
cars = 100;
/// Designates 4 people to be the space in a car
space_in_a_car = 4;
/// Designates 30 people to drive cars
drivers = 30;
/// 90 people per car
passengers = 90;
/// empty cars is the cars minus number of drivers
cars_not_driven = cars - drivers;
/// Cars driven is same as drivers
cars_driven = drivers;
/// Passenger capacity is 4 times cars driven
carpool_capacity = cars_driven * space_in_a_car;
/// average number of 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