Write an application that asks a user to type an odd number

Write an application that asks a user to type an odd number to continue or to type 999 to stop. When the user types an odd number, display the message \"Good job!\" and then ask for another input. When the user types an even number, display an error message and then ask for another input. When the user types 999, end the program. Save the file as OddEntryLoop.java. Again, Don\'t lot get to create the application/projects EvenEntryLoop Test.java Class that has the main method and an object to use the EvenEntryLoop class

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();
}
}

 Write an application that asks a user to type an odd number to continue or to type 999 to stop. When the user types an odd number, display the message \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site