0
Java 18.2
Show me solution to the problem please Write a program that takes a number N as input and outputs numbers from N to 0, skipping multiples of 3. Sample input 7 Result example 7 5 4 2 1 0
19 Respostas
+ 3
Put a condition in the loop that if (i%3==0). continue
0
they shouldn't be
0
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner read = new Scanner(System.in);
int N = read.nextInt();
for(int i = N; i >= 0; i--){
if(i%3==0)
continue;
System.out.println(i);
}
}}
//Check this
0
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner read = new Scanner(System.in);
int N = read.nextInt();
for(int i = N; i >= 0; i--){
if(i%3==0)
continue;
System.out.println(i);
} System.out.println("0");
}}
//Check this
0
can you explain what was wrong?
0
Do you get the answer? Do it passed all test cases?
0
Because in expected output 0 is present and remainder of any number with 0 is 0
So the if condition will continue that one
0
Do you get the answer? Do it passed all test cases?
Answer this question first
0
Run for loop and add if(n%3==0) that's it hope it helps you :)!!
0
Karthik Reddy Thotamgari But what about the 0 at the last?
0
Atul i forgot abt that thanks
0
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int number;
do {
//take input and output corresponding message
/*
1 => Language selection
2 => Customer support
3 => Check the balance
4 => Check loan balance
0 => Exit
*/
number=scanner.nextInt() ;
if(number==1)
{
System.out.println("Language selection");
}
else if(number==2)
{
System.out.println("Customer support");
}
else if(number==3)
{
System.out.println("Check the balance");
}
else if(number==4)
{
System.out.println("Check loan balance");
}
else
break;
}
while(number != 0);
System.out.println("Exit");
}
}
0
i've missed a case when i gave the response in 2021 and completely forgot abt that. just now saw this question again so answered, hope this helps :)
public class Main {
public static void main(String[] args) {
int n = 7;
call(n);
}
public static void call(int n){
if(n == 0){
System.out.println(n);
return;
}
if (n%3!=0){
System.out.println(n);
}
call(n-1);
}
}
- 1
Please post the question and answer
- 1
My code
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner read = new Scanner(System.in);
int N = read.nextInt();
for(int i = N; i >= 0; i--){
System.out.println(i);
}
}
- 1
no digits divisible by 3
- 1
No in the loop you do divisibles of 3 will come
- 1
Wrong
- 1
Why println (ā0ā)? why did it prevent me from writing the program? nonsense