Task 2 Using the for-loop structure, write a program that reads in a maximum of ten positive numbers from the user and display the largest number that the user entered. If the user enters a negative number at any point, your loop should immediately terminate and print the largest number as normal. For example, for the inputs: 1 30 128 60 100 -1 The output of the program would be: You entered 5 numbers, the largest of which was 128.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter5: Control Structures Ii (repetition)
Section: Chapter Questions
Problem 36SA
icon
Related questions
Question

This is a java assignment. I have attached it in the image file.

Task 2
Using the for-loop structure, write a program that reads in a maximum of ten positive numbers from the
user and display the largest number that the user entered. If the user enters a negative number at any
point, your loop should immediately terminate and print the largest number as normal. For example, for
the inputs:
1
30
128
60
100
-1
The output of the program would be:
You entered 5 numbers, the largest of which was 128.
Transcribed Image Text:Task 2 Using the for-loop structure, write a program that reads in a maximum of ten positive numbers from the user and display the largest number that the user entered. If the user enters a negative number at any point, your loop should immediately terminate and print the largest number as normal. For example, for the inputs: 1 30 128 60 100 -1 The output of the program would be: You entered 5 numbers, the largest of which was 128.
Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Types of Loop
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++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,