Assignment #12 VariablesAndNames
/// Name: Lacey Reese
/// Period: 5
/// Program Name: VariablesAndNames
/// File Name: VariablesAndNames.java
/// Date Finished 9/16/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;
// if you change 4 to 4.0 nothing changes.
// floating point= no fixed number of digits before and after the decimal point, and decimal can move
// = assigns the value on the right to a variable on the left.
// _ is an underscore character
cars = 100;
// If I put it as 4 it doesn't change anything about it, space in a car
space_in_a_car = 4.0;
// There are 30 drivers
drivers = 30;
// There are 90 passengers. The = means it assigns values to the right to a variable of the left.
passengers = 90;
// Cars not driven is the total amount of cars, minus the total amount of drivers which is 70.
cars_not_driven = cars - drivers;
// one driver per car
cars_driven = drivers;
// how many passengers can we take? Minusseat taken by driver
carpool_capacity = cars_driven * space_in_a_car;
// The average person per car is passengers divided by cars driven which is 120 divided by 30 is 4. How many do we have to put in each 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