boolean isHappy;
Scanner in = new Scanner(System.in);
System.out.print("Are you happy? ");
String answer = in.next();
if (answer.equalsIgnoreCase("yes")){
isHappy = true;
}
else {
isHappy = false;
}
|
This program will compute the proper change from a purchase. Please enter the purchase amount: $1.32 Please enter the payment amount: $20 The change is :
1 FIVE(S) 3 ONE(S) 2 QUARTER(S) 1 DIME(S) 1 NICKEL(S) 3 PENNIES |
|
This program will compute the proper change from a purchase. Please enter the purchase amount: $-1 The purchase amount has an error! The purchase amount must be at least 1 cent. |
|
This program will compute the proper change from a purchase. Please enter the purchase amount: $7.32 Please enter the payment amount: $5 The payment amount has an error. Payment amount must be at greater than or equal to the purchase amount. |
PLAYER: 0
The computer has randomly selected PAPER. SORRY, YOU LOST! The computer won because PAPER dominates (wraps) ROCK. |