Assignemnt #35 and Else.java
Code
/// Name: Boris Kazantsev
/// Period: 6
/// Program Name: Else
/// File Name: Else.java
/// Date Finished: 10/23/2015
public class Else{
public static void main(String[] args){
int people = 40, cars = 40, buses = 115;
if ( cars > people ){
System.out.println("We should ride cars.");
}// asking if there are more cars than people, then say "We should take cars."
else if ( cars < people ){
System.out.println("We should not ride cars.");
} // else if prevents java from launching else statement.
// also, if we take off "else", we are making a new if statement, asking if there are more people than cars.
// However, if we put "else if", we are connecting first if statement and else statement.
else {
System.out.println("We can't decide.");
}// asking if there are less cars than people, then say "We can't decide."
if ( buses > cars ) {
System.out.println("That's too many buses.");
}
else if ( buses < cars ) {
System.out.println("Maybe we could take the buses.");
}
else {
System.out.println("We still can't decide");
}
if ( people > buses ){
System.out.println("All right, let's just take the buses.");
}
else {
System.out.println("Fine, lets stay home then.");
}
}
}
Picture of the output