Assignemnt #12 - VariablesAndNames.java

Code

    /// Name: Boris Kazantsev
    /// Period: 6
    /// Program Name: VariablesAndNames
    /// File Name: VariablesAndNames.java
    /// Date Finished: 9/29/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; // these variables are "floating point" nubmers
                        
            cars = 100;
            space_in_a_car = 4.0; // because of "double space_in_a_car", we need to use "floating point" number.
            drivers = 30;
            passengers = 90;
            cars_not_driven = cars - drivers; // 100 - 30 = 70
            cars_driven = drivers; // 30
            carpool_capacity = cars_driven * space_in_a_car; // 30 * 4.0 = 120.0
            average_passengers_per_car = passengers / cars_driven; // 90 / 30 = 3
            
            System.out.println( "There are " + cars + " cars available."); // 100
            System.out.println( "There are only " + drivers + " drivers available."); // 30
            System.out.println( "There will be " + cars_not_driven + " empty cars today."); // 70  
            System.out.println( "We can transport " + carpool_capacity + " people today."); //120
            System.out.println( "We have " + passengers + " to carpool today.");// 90
            System.out.println( "We need to put about " + average_passengers_per_car + " in each car."); // 3
        }
    }
    

Problems

"double" creates a "floating point" nubmer, for example, 12.0.

Picture of the output

Assignment 12