Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

What were your most important educational experiences?

Answered: 1 week ago

Question

Which personal relationships influenced you the most?

Answered: 1 week ago