import java.util.Scanner ;
public class ProcessNumbers
{
public static void main( String[] args )
{
Scanner in = new Scanner(System.in) ;
System.out.print("Please enter an integer between 6 and 12, inclusive: ") ;
int num = in.nextInt() ;
boolean result = shouldProcess(num);
String result1 = processInput(result) ;
}
public static boolean shouldProcess(int n)
{
if (n>=6 && n<12)
{
return true;
}
else
{
return false;
{
}
public static String processInput(String result2)
{
if (result2 = result)
{
System.out.println("Yes") ;
}
else
{
System.out.println("No") ;
}
}
}
I am trying to work through an example that wants me to code a program where a boolean
method shouldProcess
returns true
if the number given by the user is between 6 and 12, which I have done. Next, I want to use the method called processInput
which uses the previous shouldProcess
to see if the value is true
or false
. If it is true
I will then go on to do some other calculations; however if it is false then I want to say that the number is not valid.
When I input a value, I get this error:
[File: /ProcessNumbers.java Line: 27, Column: 10] illegal start of expression
[File: /ProcessNumbers.java Line: 27, Column: 17] illegal start of expression
[File: /ProcessNumbers.java Line: 27, Column: 30] ';' expected
[File: /ProcessNumbers.java Line: 27, Column: 50] ')' expected
[File: /ProcessNumbers.java Line: 27, Column: 58] illegal start of expression
[File: /ProcessNumbers.java Line: 27, Column: 59] ';' expected
[File: /ProcessNumbers.java Line: 38, Column: 2] reached end of file while parsing
Aucun commentaire:
Enregistrer un commentaire