Assignemnt #12: Variables and Names
Code
/// Name: Cassie
/// Period: 6
/// Program Name: Variables and Names
/// File Name: VariablesandNames.java
/// Date Finished: 9/15/2016
public class VariablesandNames
{
public static void main( String[] args )
{
// states the variables being used
int cars, drivers, passengers, cars_not_driven, cars_driven;
double space_in_a_car, carpool_capacity, average_passengers_per_car;
// states the vaule for each variable
cars = 100;
space_in_a_car = 4.0;
drivers = 30;
passengers = 90;
// will print the difference of( cars - drivers ) as the amount of empty cars
cars_not_driven = cars - drivers;
// will print the amount of cars driven which is equal to the number of drivers
cars_driven = drivers;
// will print the number of people needed to be driven by multiplying cars driven by space in the car
carpool_capacity = cars_driven * space_in_a_car;
// will print the amount of people that are able to fit in each car by dividing passengers by cars driven
average_passengers_per_car = passengers / cars_driven;
// prints the text written in the quotation marks
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