Assignment # 12 and Variables And Names

Code

    /// Name: Tommy Oyuntseren
    /// Period: 7
    /// Program Name: VariablesAndNames 
    /// File Name: VariablesAndNames.java
    /// Date Finished: 9/23/15
  
  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;
        
        // assigns number of cars
        cars = 100;
        
        //assigns the amount of space available in that car
        space_in_a_car = 4.0;
        
        //anounces the number of drivers
        drivers = 30;
        
        //announces the number of passengers
        passengers = 90;
        
        //calculates number of cars not used
        cars_not_driven = cars - drivers;
        
        //calculates number of cars that are driven
        cars_driven = drivers;
        
        //calculates the number of people who are carpooled based on various variables
        carpool_capacity = cars_driven * space_in_a_car;
        
        //calculates average amount of passengers 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

Assignment 12