Ask the user for a filename that contains an unknown number of integers. Print the numbers one per line on the screen, then tell which one is the largest.
Ask the user for a filename that contains an unknown number of integers. Print the numbers one per line on the screen, then tell which one is the largest.
Ask the user for a filename that contains an unknown number of integers. Print the numbers one per line on the screen, then tell which one is the largest.
Transcribed Image Text:General Program Format Rules
Each program should have
1. A heading comment at the top of the program that contains information in this
form:
/*
Programmer
I. Will Ritem
:
Date due
: July 12, 2020
Description : This program will calculate the average
of three integers from the user
*/
A comment above each function (other than main) in this form:
/ *
: getAverage
: 3 integers
: This function will calculate the average
of its three integer parameters
: the average (a double)
Function
Receives
Description
Returns
Preconditions : none
* /
Note: preconditions are what the function is assuming to be true in order to do its job. For instance,
a function that calculates the square root of its parameter can be written one of two ways:
With no preconditions, which means the function itself must check to see if its parameter is not a
negative number, OR
а.
b. Have a precondition that the parameter is non-negative, in which case it's the caller's
responsibility to make sure the parameter is non-negative before calling the function. A
precondition is like a contract in which the function says "Ill do this, but first you're promising my
precondition is met."
3. Variables and constants with descriptive names
"average" instead of "ave", and so on.
– so, "radius" instead of "rad", "area" instead of "ar",
Please don't use global variables unless a program says it's OK. If you don't know what a global
variable is, please learn about them in section 6.10 in the text. Using global constants, on the other
hand, is fine (also in section 6.10).
4.
The order that parts of your program should follow is like this:
Heading comment (#1 above)
b.
а.
#includes section
using namespace std;
d.
C.
global constants (Note: this doesn't say global variables, which aren't allowed)
typedefs and struct declarations
f.
е.
g.
h.
function prototypes
the main () function
other functions, each with its own comment (#2 above)
6.
Please don't "hardcode" array boundaries when using loops, functions, etc. Instead, declare a global
constant (see 5d above) like this:
const int ARRAY SIZE = 25;
then write the loop like this:
for (int x
= 0; x < ARRAY SIZE; x++)
and not like this:
for (int x = 0; x <(25/; x++)
2.
5.
Transcribed Image Text:You will be using Visual Studio to create the following programs. Make sure you
see that these are separate programs.
1.
2.
Make sure that you follow the General Program Format Rules for each program
3.
The closer the form of your output matches that shown in the example
Special instructions
Make sure the input files are in the same folder as your source code! If you don't, you'll be stuck with
entering long pathnames to get to the files.
For instance, if I were working on PA1prog, I
want to put my input file in the PA1prog folder.
Here, the input file is named "pract2.txt".
Local Disk (C:) > VS Projects > PA1prog
Name
Date modified
Туре
Size
.VS
9/2/2020 3:22 PM
File folder
Debug
10/18/2020 10:22 AM
File folder
PA1prog.cpp
10/18/2020 10:21 AM
CPP File
1 KB
PA1prog.sln
A PA1prog.vcxproj
9/2/2020 3:22 PM
Visual Studio Solu...
2 KB
10/7/2020 7:34 PM
VC++ Project
8 KB
The reason: if you use only a filename, the
operating system will automatically look in the
folder where your program exists.
e PA1prog.vcxproj.filters
10/7/2020 7:34 PM
VC ++ Project Filte...
1 KB
PA1prog.vcxproj.user
9/2/2020 3:22 PM
Per-User Project ...
1 KB
pract2.txt
10/18/2020 10:18 AM
Text Document
1 KB
Source.cpp
10/7/2020 4:58 PM
CPP File
4 KB
When you save output to a file using only the filename, the file will be in the same folder as your
program, also.
Question:
Ask the user for a filename that contains an unknown number of integers. Print the numbers one per line
on the screen, then tell which one is the largest.
Note: 1. I'm including a test file named "pract3.txt". Its largest value is 4999.
2. Make sure to test to see if the file actually opened. If not, print an error message and don't
do anything else. If it did open, go ahead with the input, processing, and output.
3. Use the King of the Mountain technique for this program.
4. You will need to use a while loop that checks for when the end of the file is reached.
5. You can declare only two ints in this program. No other number variables are allowed.
扇
Process by which instructions are given to a computer, software program, or application using code.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
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.