Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Im looking for a specific assignment for C++ This assignment takes two input files and two output files and its all processed by a for

Im looking for a specific assignment for C++

This assignment takes two input files and two output files and its all processed by a for loop.

I dont even know where to start. Except I do have the input files setup with the data.... that's it though

///REMEMBER you are to complete this IPO and ONLY complete the lines where there is a // ///followed by a blank or a dash ///DELETE these 3 comment lines when you complete the IPO //-------------------------------------IPO BLOCK---------------------------------------------------- ///Programmer's Name: Your name HERE ///Program: Lab 3B ///Program Flow (IPO): ///Open the input & output files ///Output the divider to the screen ///Output file name messages to the screen ///Output the divider to the screen ///Set fixed point output for values to the output file ///Output the divider to the output file ///Output the College name, course & programmer's name to the output file ///Output the divider to the output file ///Output the course heading to the output file ///Output the divider to the output file ///Output the divider to the output file ///Output the Olympian heading to the output file ///Output the divider to the output file ///Initialize the 3 grand total bonuses for each medal & the total of all bonuses // // // // ///Input the number of Olympians from the input file ///for each Olympian to the number of Olympians: // // // // // // // // Output the Olympian number , the name, the count of gold, silver, /// & bronze medal to the output file /// Output the total medals earned to the output file /// Output the gold, silver & bronze money bonuses to the output file /// Output the total bonus earned by this Olympian to the output file ///end for /// ///Output the divider to the output file ///Output the grand totals to the output file ///Output the divider to the output file ///Close the input & Output files //--------------------------------------------------------------------------------------------------

Problem Statement 3B: FOR LOOP PROCESSING

In one of two input files, OlympianData1.txt or OlympianData2.txt, the data for all the Olympians can be found. The first line of data in the input file is the number of Olympians to process. The next lines of data include their first name on one line and the number of each type of medal that they won on the next line in the input file. (These are Gold, Silver or Bronze) Calculate the amount of bonus money earned by each athletic for each type of medal and the total bonus money earned by each athletic. The US Olympic Committee awards $25,000 for Gold Medals won, $15,000 for Silver Medals won & $10,000 for Bronze Medals won. Calculate the total bonus money earned for each type of medal for all athletics AND the grand total of all the bonus money earned by all athletics. All output will go to the output file, MedalResults1.txt or MedalResults2.txt. Include all the same output for the Olympians that was found in Lab 2. Make sure all money amounts are output with 2 decimals. The only additional calculation and output is the grand total of money earned.

The first input file that you will create, OlympianData1.txt: (the line numbers are just shown to assure you create the correct number of lines of data and should NOT be typed)

The second input file that you will create, OlympianData2.txt: (the line numbers are just shown to assure you create the correct number of lines of data and should NOT be typed)

Instructions:

Create a new Visual Studio C++ Project, naming the project/folder: LastNameFirstInitialLab3B A. So if your name is John Smith, you would name the project: SmithJLab3B

Add an empty .cpp file to the project, name it: LastNameFirstInitialLab3B A. So if your name is John Smith, you would name the .cpp file SmithJLab3B

At the top of every project that you create for this course, you will include a grading block and under that grading block you will create the main doc block which includes the IPO for the programThe IPO shows the flow of the program

It is the outline of the tasks that need to be performed to solve the problem ii. It is used the specify the order of the steps to be completed in the code

You will be completing the IPO for this problemThe provided lines for the IPO will be shown with ///, the lines you must complete will be blank and will start with //

You should not need to add additional lines to the IPO

Insert the grading block & the main doc block provided: Lab 3BGradeAndDocBlk

As you write the solution for this problem, complete the IPO

From the problem statement & the IPO for 3B:

You should be able to use the same preprocessor directives and constants that were created for Lab 2 A. The only additional preprocessor directive that you need is for the file processing

Create the two input files

Click on Project/Add new Item

Click on Utility/ Text File(.txt)

Type the name for the first input file, OlympianData1.txt

Type the data shown above on the appropriate lines for this first input file ii. Save this file

Click on Project/Add new Item

Click on Utility/ Text File(.txt)

Type the name for the second input file, OlympianData2.txt

Type the data shown above on the appropriate lines for this second input file ii. Save this file

Create the main functionStart with meaningful variable names for all the assigned and calculated values of ONE Olympian

REMEMBER, we will re-use many of these variables for EACH Olympian in the loop

To help you and your professor find the sections of your code, we are going to include comment dividers in each section of the code i. These are:

1) The Initial Setup of the Program

A) This includes the code to open the files, the file location messages output on the screen, the set of the precision for the output file, output the course heading to the output file & any initializations needed

i) We all know that this section of code should appear ONCE and only once in the code 2) The output of the columned heading for the data and the calculations to the output file A) This also only appears once 3) The Initializations

A) This includes initializing the accumulators and the input of the number of Olympians from the input

file

The processing loop for the Olympians

The output of the grand totals

The closing of the files ii. You should have 7 divider comments in the code iii. Example divider comment:

You should be able to copy the code from Lab 2 and edited it:Change the input statements to be processed from an input file

For the first run of the program, open the input file, OlympianData1.txt and the output file MedalResults1.txt in the code B. This input includes:

The number of Olympians to be used to process the for loop

The Olympians first name and the number of each of the 3 types of medals

This input will be input in the loop

As the Olympians names are just one word, the name can be input using standard input A) (You dont need to use a getline)

Eliminate the duplicate processing code

Change the output to be written to the output file

Add the code to output on the screen the file names

i. This output should look like this for the first run of the program:

ii. You do not have to copy this screen output and put it into a txt file as we have done on previous labs

Add the code to accumulate the grand total of all money earned by an Olympian

Once you have edited the code, Rebuild the Solution and correct any errors

Once the program is error free, run the program and check the formatting of the output - make sure the headings are printed and all output values right align under the heading i. Sample Output to the output file, MedalResults1.txt:

Check your calculations manually to assure that you have the correct results

Check your output with the sample output display shown above and make sure the output is written to the correct file

Once the program works correctly and you have the output file created from the first run, attached in the Solution Explorer Window and in the project folder, edit your code to change:

The opening statements for the input and the output file to the second set of file names i. OlympianData2.txt ii. MedalResults2.txt

The file name messages printed to the screen to reflect the same file namse as shown above

Start the project early and ask questions in the discussion to assure your success on this lab!

Dont forget to complete the post first answering the questions asked by your professor

Actively participate in the discussion

Make sure you have added to the project solution the input and output files; you should see these listed in the Solution Explorer Window

Mod 3B notes explains how to do this

The Solution Explorer Window should look like this with the cpp file named as specified at the start of the instructions for this part of the lab:

Start the project early and ask questions in the discussion to assure your success on this lab!

Dont forget to complete the post first answering the questions asked by your professor

Actively participate in the discussion

In the project folder, delete (if created):

Debug Folder, vs Folder, x64 Folder

.VC file -The Database File

Zip the project folder using the Windows Compression Utility

Submit the ZIPPED folder to the Assignment submission link Lab 3B in Blackboard by the due date and time shown in the course calendar

Input files

OlympianData1.txt

1 4 2 Mike 3 23 2 3 4 Ryan 5 5 3 1 6 Simone 7 8 4 2 8 Ally 9 020

OlympianData2.txt

1 10 2 Steve 3 3 1 0 4 Ryan 5 0 0 1 6 Sara 7 4 1 1 8 Alice 9 0 2 1 10 Bob 11 3 3 3 12 Carol 13 1 1 1 14 Ted 15 5 3 2 16 Kelsey 17 1 0 2 18 Chris 19 0 3 0 20 Jim 21 0 4 4

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions