#36 Please code in C++ Write a program that prompts the user to enter 5 integers (1 at a time), find the maximum, and prints
#36
Please code in C++
Write a program that prompts the user to enter 5 integers (1 at a time), find the maximum, and prints the results to a file called results.txt. Each value entered by the user should be printed to the file after the word Values: , and the maximum printed on a separate line after the word Max: . Specifications: Create a project called HW36 in NetBeans with a main.cpp source file. Make sure that the first line of main.cpp is /* Homework 36 */. Use a constant N to define the number of integers to be read into the program (5). The program should use a for loop to prompt the user to enter an integer. Use the prompt: Enter a Number: As you enter each number, print it to the file with a space between each number. To calculate the maximum, the first time you enter a number set it to the maximum; then each time next through the loop if the new number entered is greater than the current maximum, set it to the new maximum. Once the loop ends print the maximum to the file. You must use the following constants and variable names for your program: N constant integer set to 5 (the number of values to be read in) fout output file stream object for writing data to the file x integer that stores the current number max integer that stores the maximum number If you execute the program with the following underlined input, the results will be: ~> main.o Enter a number: 5 Enter a number: 3 Enter a number: 7 Enter a number: 9 Enter a number: 2 ~> more results.txt Values: 5 3 7 9 2 Max: 9 ~> When you have double checked your work, raise your hand to demonstrate your code. Then submit to the grader program. Use the back page for your Algorithmic Development. This should include your I/O diagram, and the algorithm/pseudocode used to solve the problem.
Write a program that prompts the user to enter 5 integers (1 at a time), find the maximum, and prints the results to a file called "results.txt. Each value entered by the user should be printed to the file after the word Values: and the maximum printed on a separate line after the word Max: " Specifications: Create a project called HW36 in NetBeans with a main.cpp source file. Make sure that the first line of main.cpp is /*Homework 36 / Use a constant N to define the number of integers to be read into the program (5). The program should use a for loop to p pt the user to enter an integer. Use the prompt: Enter a Number: As you enter each number, print it to the file with a space between each number. To calculate the maximum, the first time you enter a number set it to the maximum; then each time next through the loop if the new number entered is greater than the current maximum, set it to the new maximum. Once the loop ends print the maximum to the file. You must use the following constants and variable names for N constant integer set to 5 (the number of values to be read in) fout output file stream object for writing data to the file x integer that stores the current number max integer that stores the maximum number If you execute the program with the following underlined input, the results will be: -> main.o Enter a number: Enter a number: 3 Enter a number: 7 Enter a number: 9 Enter a number: 2 - more results.txt Values: 5 3 7 9 2 Max: 9 When you have double checked your work, raise your hand to demonstrate your code. Then submit to the grader program. Use the back page for your Algorithmic Development. This should include your I/O diagram, used to solve theStep by Step Solution
There are 3 Steps involved in it
Step: 1
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