How do I change the error to a success? import java.lang.Math; import java.util.Scanner; public class MidtermProblems { public static String odds(int a) { int odds; odds = a; String s; if(odds > 0) { //s = odds; return "" + odds; } else if(odds < 0) { s = "None"; } else { s = ""; } return s; } public static void main(String[] args) { Scanner in = new Scanner(System.in); int a=0; a = in.nextInt(); //Add Loop to get odd Numbers if(a<0) { System.out.println(odds(a)); } else { for(int i=1;i<=a;i=i+2){ System.out.print(odds(i)+" "); } } //String result = odds(a);Not Required //result = Main.odds(a); Not Required } }
How do I change the error to a success?
import java.lang.Math;
import java.util.Scanner;
public class MidtermProblems
{
public static String odds(int a)
{
int odds;
odds = a;
String s;
if(odds > 0)
{
//s = odds;
return "" + odds;
}
else if(odds < 0)
{
s = "None";
}
else
{
s = "";
}
return s;
}
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int a=0;
a = in.nextInt();
//Add Loop to get odd Numbers
if(a<0) {
System.out.println(odds(a));
}
else {
for(int i=1;i<=a;i=i+2){
System.out.print(odds(i)+" ");
}
}
//String result = odds(a);Not Required
//result = Main.odds(a); Not Required
}
}
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images