Assignemnt #12 and VariablesAndNames
Code
///Name: Joshua Bautista
///Period: 6
///Project Name: Variables And Names
///File Name: VariablesAndNames.java
///Date: 9/14/2015
// 1- Using 4.0 for space_in_car is not necessary since 4 will give same answer without the point
// 2- Floating point numbers are numbers that have no fixed number before and after point
public class VariablesAndNames
{
public static void main( String[] args )
{
// Making each word a variable so the computer can provess
int cars, drivers, passengers, cars_not_driven, cars_driven;
double space_in_a_car, carpool_capacity, average_passengers_per_car;
// Making each variable have a certain number attached to it
cars = 100;
space_in_a_car = 4.0;
drivers = 30;
passengers = 90;
// Telling computer to subtract certain variables
cars_not_driven = cars - drivers;
cars_driven = drivers;
carpool_capacity = cars_driven * space_in_a_car;
average_passengers_per_car = passengers / cars_driven;
// Making the stuff in quotes into sentences then adding the car variable into the sentence
System.out.println( "There are " + cars + " cars available." );
System.out.println( "There are only " + drivers + " drivers available." );
// Telling computer to subtract varibale of cars and drivers then using answer in sentence
System.out.println( "There will be " + cars_not_driven + " empty cars today." );
// Telling computer to multiply variable of cars driven and space in cars then use answer in sentence
System.out.println( "We can transport " + carpool_capacity + " people today." );
//Using the number attached to the passenger variable into the sentence
System.out.println( "We have " + passengers + " to carpool today." );
//Using the average_passenger_per_car varriable which tells computer to divide passengers and cars_driven variables, then putting the answer in the sentence.
System.out.println( "We need to put about " + average_passengers_per_car + " in each car." );
}
}
Picture of the output