I need Help in Java-Practice 14.3 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I need Help in Java-Practice 14.3

Hi Could you help me to get the right solution of the Java-Practice 14.3? It's about Logical Statemnts and the name of the practice is "Lucky Winter". Thank you.

11th Jan 2022, 2:21 AM
Decoder21
6 Answers
+ 5
Would you please show your attempt here ?
11th Jan 2022, 2:42 AM
Aysha
Aysha - avatar
+ 2
Decoder21 you probably need to move your 2nd if statement and nest it under your 1st. I'd change it to "else if" as well.
11th Jan 2022, 10:30 PM
Ausgrindtube
Ausgrindtube - avatar
+ 1
Copy your code into the code playground and then share the code here. Then, someone can have a look and hopefully help.
11th Jan 2022, 8:50 PM
Ausgrindtube
Ausgrindtube - avatar
+ 1
Hi sorry for the late answer. Here is my code. import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner read = new Scanner(System.in); int number = read.nextInt(); if (number %10==0 && number %9==0) System.out.println("You won $200"); else System.out.println("Try again"); if (number %6==0 ||number %4==0) System.out.println("You won $50"); else System.out.println("Try again");
11th Jan 2022, 10:22 PM
Decoder21
+ 1
Ausgrindtube it didn't work. Could you please show it here?
11th Jan 2022, 10:42 PM
Decoder21
+ 1
If(number %10 == 0 && number %9 ==0) System... Else if(number %6 == 0 || number %4 ==0) System... Else System... I think.
12th Jan 2022, 8:03 AM
Ausgrindtube
Ausgrindtube - avatar