my code is not able to pass the test case 1
Code not passing test case 1
@jatin111,
Here is the corrected code: https://ide.codingblocks.com/s/201983
Error:
Don’t use the following if condition. This is causing the error.
if (m > 0 && m < 100 && n > m && n < 500 && o > 0) {
import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int c;
int m = sc.nextInt();
int n = sc.nextInt();
int o = sc.nextInt();
// if (m > 0 && m < 100 && n > m && n < 500 && o > 0) {
while (m <= n) {
c = (int) ((m - 32) * 5) / 9;
System.out.print(m + "\t");
m = m + o;
System.out.println(c);
// }
}
}
}
Corrected code.
i cant understand the correction you have made
@jatin111,
In your code the following statement is giving you an error:
if (m > 0 && m < 100 && n > m && n < 500 && o > 0) {
For the sample input:
0
100
20
Your code will not give any output because m=0. Also, you don’t need this statement. If you are given the constraints in a question it is to tell you what the complexity of your code should be.
but i have given the same constraints as mentioned in the ques and the code you have provided is showing errors
Yes, there has been an error in the constraints part of the question but that’s not the point.
You need to test your code for the sample test case, it will not give any output for that because of your if condition.
Also, I have myself submitted the code I have sent you and it is working fine. Can you please elaborate more on what error are you exactly facing or attach a screenshot of the same?
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.
can you please do the changes in my code and correct the code that i have written wrong
here working code
import java.util.*;
import java.util.Scanner;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
double c;
int m = sc.nextInt();
int n = sc.nextInt();
int o = sc.nextInt();
while (m <= n) {
double temp=5.0/9;
c =(m - 32)*temp;
System.out.println(m+" "+(int)c);
m = m + o;
}
}
}
code is still showing error and i cant understand the line (m <= n)
@jatin111
the code is correct and m<=n means that m=minimum && n=maximum so while minimum <=maximum
we have to do the following operations
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.