Question
Write a java program to read whole numbers (integers) until a sentinel (any negative number can act as sentinel) is entered and perform the following:
Write a java program to read whole numbers (integers) until a sentinel (any negative number can act as sentinel) is entered and perform the following:
(1) Display a menu for the user as follows:
0 for two-digit numbers
1 for three-digit numbers
2 for four-digit numbers
3 for more than four digits
4 sentinel (any negative number)
If the user selects an option and enters an invalid number, display an appropriate error message, and reject the input.
(2) Display sum of the even numbers between 10 and 999.
(3) Display sum of the odd number less than 9999.
(4) Display average of the three-digit numbers.
//**************************************************************************
//
// DESCRIPTION: Program reads integers and performs sum of the even and odd numbers
// and the average
// CLASS: COSC 1437
// AUTHOR:
//
//**************************************************************************
public static void main(String[] args) {
// add your statements here
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started