Question: Problem #1: Write a program in Java to ask a user for input of a number. Check whether a number is even or odd and

Problem #1: Write a program in Java to ask a user for input of a number. Check whether a number is even or odd and display a message to that effect. Keep asking for input from the user until the user enters a code that designates to QUIT.

Here is what I have so far:

import java.util.Scanner;

public class OddEven {

public static void main(String[] args) { Scanner reader = new Scanner(System.in); System.out.print("Enter a number: "); int num = reader.nextInt(); if (num % 2 == 0) System.out.println(num + " is even"); else System.out.println(num + " is odd"); System.out.print ("Enter another number or enter quit to stop: ");

} }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!