The grade 7 pupils of Sunnyside Primary School have three entrepreneur days per
ID: 3627699 • Letter: T
Question
The grade 7 pupils of Sunnyside Primary School have three entrepreneur days per month for certain months of theyear. Your task is to write a program that will determine the highest profit amount for each month, as well as the total
profit for the whole year, by reading the data from the input file below. The file contains the names of the months,
followed by the profit amount for the three entrepreneur days for each of the months. Use a variable of type string
to read the month, and three variables of type float to read in the profit amount for the three entrepreneur days per
month. Create an input file profit.dat containing the following data:
Feb 310.60 1200.60 980.70
Apr 1111.20 1345.45 760.40
Jun 666.80 1200.60 1430.90
Aug 1908.10 1040.50 1746.50
Sep 1090.70 770.70 712.30
Nov 432.30 1257.80 1278.40
Create an output file best.dat containing the highest profit for each month, as well as the total profit for the
year.
For the above input file the output file should be:
Feb 1200.60
Apr 1345.45
Jun 1430.90
Aug 1908.10
Sep 1090.70
Nov 1278.40
Total profit for the year: 19244.55
Explanation / Answer
#include #include using namespace std; int main() { ifstream fin("profit.dat"); ofstream fout("best.dat"); float total=0.0; for(int k=0; k> str; fout > n2 >> n3; total+=n1+n2+n3; if(n1>n2) n2=n1; if(n2>n3) n3=n2; foutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.