a guest Mar 20th, 2017 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- C++ Program
- Write a program that accepts the following input from the keyboard:
- -a first name
- -a last Name
- -The scores on three tests (scores will range from 0 to 10). They type should be double
- The program will calculate the average of the three scores entered from the keyboard
- and store the average as a rounded integer (ex. If the average is 7.57 then it will be
- stored as 8, but if it was 6.49, then it will be stored as 6)
- Then, using the rounded average calculate the corresponding course letter grade using
- the scoring system below. You must use a switch statement to get the letter grade.
- The simplified scoring system will be:
- 9-10 A
- 8 B
- 7 B6
- 5 C
- 4 D+
- 0-3 F
- Once all of the data has been processed (entered, stored and average and letter grades
- have computed) display on your monitor (cout) the results in the following way:
- The dashes were produced by adding setfill('-') to the output.
- Once you are satisfied that your output is correct and properly lined up, send the same
- output to a file. Use “example.txt” as the file name. The file will be created in the same
- directory as your program. You can use File/Open in Dev-C++ to access that directory
- (i.e. folder) and see if the contents of the file match what you displayed on your
- monitor. They should!!!
- To find more about how to output to files, read pages 160-161 (File input output).
- There you will see how to create a file for output (and input, but this time we will do
- only output). Once you have created the file stream associated with file example.txt,
- you can output to that file stream the same as you do to cout. In fact, you can think of
- cout as a file stream associated with your monitor, instead with a real file on disk.
- In order to make all the above work you need to include:
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <iomanip>
- using namespace std;
- It is important that you name the output file as I indicated (“example.txt”), since when I
- run your program I will expect it to create a file of the same name on my computer that
- I will have to check to make sure your output is correct.
RAW Paste Data