+ 1
The OR operator
I am working in Lucky Winner (PRO) and cannot figure how to write the code. The hint says Number a is a multiple of number b, if a%b == 0. Am I to make variables for the number for the multiples? multiple of 10 and 9 a = 10 b = 9 scanner input number then number %a && number%b == 0
5 Antworten
+ 1
Hi! your condition says that the program should:
1. output "you won $ 200" if the number is BOTH a multiple of 10 AND 9.
2. output "you won $ 50" if the number is a multiple of only 4 OR 6.
3. in all other cases, it should output something else.
what thoughts do you have about this?
+ 1
Can you show your code?
0
Okay I think it is not working because if am not putting (). I will try that. Thanks
0
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner read = new Scanner(System.in);
int number = read.nextInt();
//your code goes here
if(number%10 == 0 && number%9 == 0){
System.out.println("You won $200");
}
else if(number%4 == 0 || number%6 == 0){
System.out.println("You won $50");
}
else{
System.out.println("Try again");
}
}
}
if took a couple of tries because I want writing the first if statement correct and not using else if -- a newbee Thanks for the help
0
Congratulations! your program has passed all the tests! 🥳