0

Java 16.2 Task 4

Please copy the conditions of the task 4

20th Apr 2021, 3:08 PM
Igaman Igaman
Igaman Igaman - avatar
7 ответов
+ 6
Please, share your attempt for further help.
20th Apr 2021, 3:13 PM
Shivani 📚✍
Shivani 📚✍ - avatar
+ 2
Thank you !
20th Apr 2021, 4:35 PM
Igaman Igaman
Igaman Igaman - avatar
+ 1
Igaman Igaman Your code is approximately correct. Here is the correct solution. Initialise n with 1 not 3 and no need to check number > n int n = 1; while (n <= number) { if(n % 3 == 0 || n % 10 == 3) { System.out.println(n); } n++; }
20th Apr 2021, 4:21 PM
A͢J
A͢J - avatar
+ 1
Why 1???
20th Apr 2021, 4:25 PM
Igaman Igaman
Igaman Igaman - avatar
+ 1
Igaman Igaman Read problem statement again. "prints all numbers from 1 to the inputted number"....
20th Apr 2021, 4:31 PM
A͢J
A͢J - avatar
0
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner read = new Scanner(System.in); int number = read.nextInt(); int n=1; if(number>n) { while(n<=number) { if(n%3==0 || n%10==3) System.out.println(n); n++; } } } }
20th Apr 2021, 3:15 PM
Igaman Igaman
Igaman Igaman - avatar
0
i ask people to share the terms of task 4
20th Apr 2021, 4:08 PM
Igaman Igaman
Igaman Igaman - avatar