'F' → Fullscreen
public class Program {
public static void main(String[] args) { String name = "Mr. Mortimer"; int age = 30; double balance = 150.00; boolean isTeacher = true; boolean isMillionaire = false;// }}public class Program {
public static void main(String[] args) { String name = "Mr. Mortimer"; int age = 30; double balance = 150.00; boolean isTeacher = true; boolean isMillionaire = false;
// -----------------------------------------------------------------------------
System.out.println("-Name Checks-");
boolean nameIsMortimer = name.equals("Mr. Mortimer");
System.out.println("Is my name Mr. Mortimer? " + nameIsMortimer); System.out.println("Is my name Mr. Mertens? " + name.equals("Mr. Mertens")); System.out.println("My name is not Mr. Merriman: " + !name.equals("Mr. Merriman"));// }}public class Program {
public static void main(String[] args) { String name = "Mr. Mortimer"; int age = 30; double balance = 150.00; boolean isTeacher = true; boolean isMillionaire = false;
// -----------------------------------------------------------------------------
System.out.println("-Name Checks-");
boolean nameIsMortimer = name.equals("Mr. Mortimer");
System.out.println("Is my name Mr. Mortimer? " + nameIsMortimer); System.out.println("Is my name Mr. Mertens? " + name.equals("Mr. Mertens")); System.out.println("My name is not Mr. Merriman: " + !name.equals("Mr. Merriman"));
// -----------------------------------------------------------------------------
System.out.println("\n-Age-Related Checks-");
boolean canDrive = age >= 16; boolean canRentCar = age >= 25; boolean isSenior = age >= 65;
System.out.println("Am I old enough to drive? " + canDrive);
System.out.println("Am I old enough to rent a car? " + canRentCar); System.out.println("Am I eligible for a senior citizen discount? " + isSenior);// }}public class Program {
public static void main(String[] args) { String name = "Mr. Mortimer"; int age = 30; double balance = 150.00; boolean isTeacher = true; boolean isMillionaire = false;
// -----------------------------------------------------------------------------
System.out.println("-Name Checks-");
boolean nameIsMortimer = name.equals("Mr. Mortimer");
System.out.println("Is my name Mr. Mortimer? " + nameIsMortimer); System.out.println("Is my name Mr. Mertens? " + name.equals("Mr. Mertens")); System.out.println("My name is not Mr. Merriman: " + !name.equals("Mr. Merriman"));
// -----------------------------------------------------------------------------
System.out.println("\n-Age-Related Checks-");
boolean canDrive = age >= 16; boolean canRentCar = age >= 25; boolean isSenior = age >= 65;
System.out.println("Am I old enough to drive? " + canDrive);
System.out.println("Am I old enough to rent a car? " + canRentCar); System.out.println("Am I eligible for a senior citizen discount? " + isSenior);
// -----------------------------------------------------------------------------
System.out.println("\n-Bank Account Checks-");
boolean canBuyCar = balance > 31000; boolean hasFunds = balance > 0;
System.out.println("Do I have enough to buy a Dodge Challenger? " + canBuyCar); System.out.println("Do I have a positive bank balance? " + hasFunds);// }}public class Program {
public static void main(String[] args) { String name = "Mr. Mortimer"; int age = 30; double balance = 150.00; boolean isTeacher = true; boolean isMillionaire = false;
// -----------------------------------------------------------------------------
System.out.println("-Name Checks-");
boolean nameIsMortimer = name.equals("Mr. Mortimer");
System.out.println("Is my name Mr. Mortimer? " + nameIsMortimer); System.out.println("Is my name Mr. Mertens? " + name.equals("Mr. Mertens")); System.out.println("My name is not Mr. Merriman: " + !name.equals("Mr. Merriman"));
// -----------------------------------------------------------------------------
System.out.println("\n-Age-Related Checks-");
boolean canDrive = age >= 16; boolean canRentCar = age >= 25; boolean isSenior = age >= 65;
System.out.println("Am I old enough to drive? " + canDrive);
System.out.println("Am I old enough to rent a car? " + canRentCar); System.out.println("Am I eligible for a senior citizen discount? " + isSenior);
// -----------------------------------------------------------------------------
System.out.println("\n-Bank Account Checks-");
boolean canBuyCar = balance > 31000; boolean hasFunds = balance > 0;
System.out.println("Do I have enough to buy a Dodge Challenger? " + canBuyCar); System.out.println("Do I have a positive bank balance? " + hasFunds);
// -----------------------------------------------------------------------------
System.out.println("\n-Boolean Checks-");
System.out.println(name + " is a teacher: " + isTeacher); System.out.println(name + " is a millionaire: " + isMillionaire);
boolean notMillionaire = !isMillionaire; System.out.println("So, " + name + " isn't a millionaire? " + notMillionaire);// }}public class Program {
public static void main(String[] args) { String name = "Mr. Mortimer"; int age = 30; double balance = 150.00; boolean isTeacher = true; boolean isMillionaire = false;
// -----------------------------------------------------------------------------
System.out.println("-Name Checks-");
boolean nameIsMortimer = name.equals("Mr. Mortimer");
System.out.println("Is my name Mr. Mortimer? " + nameIsMortimer); System.out.println("Is my name Mr. Mertens? " + name.equals("Mr. Mertens")); System.out.println("My name is not Mr. Merriman: " + !name.equals("Mr. Merriman"));
// -----------------------------------------------------------------------------
System.out.println("\n-Age-Related Checks-");
boolean canDrive = age >= 16; boolean canRentCar = age >= 25; boolean isSenior = age >= 65;
System.out.println("Am I old enough to drive? " + canDrive);
System.out.println("Am I old enough to rent a car? " + canRentCar); System.out.println("Am I eligible for a senior citizen discount? " + isSenior);
// -----------------------------------------------------------------------------
System.out.println("\n-Bank Account Checks-");
boolean canBuyCar = balance > 31000; boolean hasFunds = balance > 0;
System.out.println("Do I have enough to buy a Dodge Challenger? " + canBuyCar); System.out.println("Do I have a positive bank balance? " + hasFunds);
// -----------------------------------------------------------------------------
System.out.println("\n-Boolean Checks-");
System.out.println(name + " is a teacher: " + isTeacher); System.out.println(name + " is a millionaire: " + isMillionaire);
boolean notMillionaire = !isMillionaire; System.out.println("So, " + name + " isn't a millionaire? " + notMillionaire);
// -----------------------------------------------------------------------------
System.out.println("\n-Logical Operator Examples-"); boolean canDriveAndBuy = canDrive && canBuyCar; System.out.println("Am I old enough to drive AND have enough to buy a Dodge Challenger? " + canDriveAndBuy); boolean canDriveOrBuy = canDrive || canBuyCar; System.out.println("Am I old enough to drive OR have enough to buy a Dodge Challenger? " + canDriveOrBuy);// }}Your program output should something similar to the sample output below.
-Name Checks-Is my name Mr. Mortimer? trueIs my name Mr. Mertens? falseMy name is not Mr. Merriman: true
-Age-Related Checks-Am I old enough to drive? trueAm I old enough to rent a car? trueAm I eligible for a senior citizen discount? false
-Bank Account Checks-Do I have enough to buy a Dodge Challenger? falseDo I have a positive bank balance? true
-Boolean Checks-Mr. Mortimer is a teacher: trueMr. Mortimer is a millionaire: falseSo, Mr. Mortimer isn't a millionaire? true
-Logical Operator Examples-Am I old enough to drive AND have enough to buy a Dodge Challenger? falseAm I old enough to drive OR have enough to buy a Dodge Challenger? trueMr. Mortimer is a millionaire: falseSo, Mr. Mortimer isn't a millionaire? true
Mr. Mortimer is a millionaire: falseMr. Mortimer is a millionaire: falseSo, Mr. Mortimer isn't a millionaire? true
-Logical Operator Examples-Am I old enough to drive AND have enough to buy a Dodge Challenger? falseAm I old enough to drive OR have enough to buy a Dodge Challenger? trueYou may write your reflection answers as comments at the bottom of your code.
Submit your activity and reflection answers to the appropriate dropbox.