Write an application that asks a user to type an odd number
Solution
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package chegg;
import java.util.Scanner;
public class OddEntryLoop {
public void execute()
{
Scanner input = new Scanner(System.in);
int num = 0;
while(true)
{
System.out.println(\"Input a number or enter 999 to exit.\");
num = input.nextInt();
if(num==999)
break;
else if(num%2==1)
System.out.println(\"Good job!\");
else if(num%2==0)
System.out.println(\"Error Message!\");
}
System.exit(0);
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package chegg;
public class OddEntryLoopTest {
public static void main(String[] args)
{
OddEntryLoop o = new OddEntryLoop();
o.execute();
}
}
