9.8k views
2 votes
There are 4 numbered instructions in the code, along with

comments that should help you to make changes.

//CHALLENGE #2 Change the code below to say WOW if 2 coins have the same value
// You only need to change the conditions.
if (( coin1 >= coin2)){
System.out.println("WOW! Two coins the same!");
} else {
System.out.println("No matches");
}

User Nolawi
by
8.2k points

1 Answer

2 votes

Answer:

if (coin1 == coin2) {

System.out.println("WOW! Two coins the same!");

} else {

System.out.println("No matches");

}

Step-by-step explanation:

In this modified code, we changed the condition to check whether coin1 is equal to coin2 using the == operator, which checks for equality. If the condition is true, meaning both coins have the same value, the code will output "WOW! Two coins the same!". If the condition is false, meaning the coins have different values, the code will output "No matches".

User Michel Arteta
by
8.2k points