Write a java program that asks a user to enter a set of positive integer values. When the user stops (think of sentinel value to stop), the program displays the maximum value entered by the user. Your program should recognize if no value is entered without using counter. Sample run: run: Enter a positive integer or (-1) to stop: 25 Enter a positive integer or (-1) to stop: 36 Enter a positive integer or (-1) to stop: 51 Enter a positive integer or (-1) to stop: -9 Maximum number entered is: 51

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter5: Repetition Statements
Section5.5: A Closer Look: Loop Programming Techniques
Problem 14E
icon
Related questions
Question
Exercise 2:
Write a java program that asks a user to enter a set of positive integer values. When the user stops
(think of sentinel value to stop), the program displays the maximum value entered by the user. Your
program should recognize if no value is entered without using counter.
Sample run:
run:
Enter a positive integer or (-1) to stop: 25
Enter a positive integer or (-1) to stop: 36
Enter a positive integer or (-1) to stop: 51
Enter a positive integer or (-1) to stop: -9
Maximum number entered is: 51
BUILD SUCCESSFUL (total time: 8 seconds)
run:
Enter a positive integer or (-1) to stop: -10
NO number is entered!
BUILD SUCCESSFUL (total time: 2 seconds)
Transcribed Image Text:Exercise 2: Write a java program that asks a user to enter a set of positive integer values. When the user stops (think of sentinel value to stop), the program displays the maximum value entered by the user. Your program should recognize if no value is entered without using counter. Sample run: run: Enter a positive integer or (-1) to stop: 25 Enter a positive integer or (-1) to stop: 36 Enter a positive integer or (-1) to stop: 51 Enter a positive integer or (-1) to stop: -9 Maximum number entered is: 51 BUILD SUCCESSFUL (total time: 8 seconds) run: Enter a positive integer or (-1) to stop: -10 NO number is entered! BUILD SUCCESSFUL (total time: 2 seconds)
Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr