Question

In: Computer Science

First Last Q0 Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q8 Q9 L0 L1 L2 L3...

First Last Q0 Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q8 Q9 L0 L1 L2 L3 L4 L5 L6 L7 L8 L9 P0 P1 P2 E0 E1 E2 FI ATT
------------------------------------------------------------------------------------------------------------------------------------------
Kevin Smith 90 100 100 100 98 97 87 100 85 87 89 100 100 100 100 90 100 98 90 100 98 98 98 90 90 98 88 0.00
Morgan Kelly 80 100 65 67 69 71 100 100 100 67 95 85 87 89 100 65 67 69 71 100 98 98 98 65 67 69 71 0.10
Isaac Newton 100 90 100 90 100 90 100 90 100 100 100 100 100 100 100 100 100 100 100 100 98 98 98 90 90 98 88 0.00
Cole Jones 100 100 100 87 73 75 77 79 81 87 89 91 73 75 77 79 81 100 100 100 98 100 65 67 69 71 63 0.05
Angela Allen 100 100 100 87 89 91 93 95 100 100 100 100 100 100 100 95 97 100 98 98 98 90 73 75 77 79 81 0.02
David Cooper 56 58 60 62 64 100 100 100 87 73 75 77 100 100 77 79 81 100 100 100 98 70 72 74 76 78 88 0.00
Nancy Bailey 100 87 89 91 93 95 100 100 100 100 100 100 91 93 95 97 100 98 100 100 98 98 98 90 90 98 88 0.00
Emily Synder 65 67 69 71 62 64 73 75 77 58 60 62 79 66 68 70 72 81 74 76 78 90 90 74 76 98 88 0.00
Lori Austin 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 98 98 98 90 90 98 88 0.02
Jenny Howard 56 58 60 62 71 62 64 73 100 66 68 70 72 74 76 78 100 100 100 60 62 79 66 68 70 68 70 0.03
Anne Lewis 100 86 58 60 100 71 62 64 73 94 66 68 90 72 74 76 78 67 68 69 70 71 98 88 76 78 68 0.04
Nick Johnson 100 100 89 91 73 75 77 79 81 100 100 100 98 100 100 95 85 87 89 100 98 98 98 80 76 78 98 0.01
Nick Spickler 100 93 95 97 100 98 98 98 90 100 89 91 93 95 97 100 100 89 91 93 95 97 98 98 90 90 98 0.00
Joy Williams 75 77 58 60 62 79 66 68 70 72 81 100 100 71 62 64 73 94 66 98 90 90 98 68 90 88 77 0.00
Barbara Hood 100 67 95 85 87 89 91 93 95 97 85 87 100 100 100 71 62 64 73 94 66 68 98 98 90 90 88 0.00
Joe Hoarn 62 63 64 65 66 67 68 69 70 71 100 81 100 100 71 62 64 73 100 100 98 98 64 73 94 66 68 0.08
Payton Bardzell 100 100 100 97 87 67 95 85 87 89 91 93 95 97 100 100 100 95 85 87 89 100 98 90 90 78 98 0.00
Kim Ludwig 71 62 64 73 75 77 58 60 62 79 66 68 70 72 81 100 100 79 66 68 70 72 98 98 90 90 98 0.09
Susan Honks 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 90 90 88 100 100 100 100 0.00

Write the program in C++ read the grades of all the students from the file above. For each student’s scores,

The program most be define arrays to keep scores for quizzes, labs, projects, midterms. Secondly, read in the grades for each student and define a function to calculate and return the average grade of quizzes, labs, projects and midterms. Sample prototype of this function: float getAverage(float gradeArray[], int arraySize); // a function to calculate average of array. Also, define a function to calculate and return the final letter grade of this student. Note the total grade, average project grade, and the attendance will be taken into consideration when the final grade is calculated. Last importantly, output this student’s first name, last name, and final letter grade in a nice format to a file named letter120.dat. Each student’s data is in one line. This file should be in the same location as data that is given from the above file. The format should be as following:

First Name Last Name Final Grade

Nick Johnson A

Anne Lewis B

Writing the program in C++ beginners

Use constants to keep the percentage values in the above table.

COMMENT YOUR CODE.

Give meaningful variable, array, and function names based on this program.

Arrays and functions are implemented properly.

The grade is calculated correctly and output file is generated properly.

Solutions

Expert Solution

#include<iostream>
#include<fstream>
#include<string>
#include<iomanip>
using namespace std;
//variables declaration
string word;
string heading[50];
string f_name[50],l_name[50];
string u_line;
int l_index=0,q_index=0,p_index=0,e_index=0;
float l[50][50],p[50][50],q[50][50],e[50][50],f[50],att[50];
int count=0,linecount=0,k;
//function prototype for two functions
char getGrade(float num);
float getAverage(float getAverage[50][50] , int);
int main()
{
float sum;
ifstream f1;
//open file in read mode
f1.open("input.dat");
while (f1 >> word)
{
//first two lines needs to skipped hence linescount is checked
if(linecount<1)
{
if(count%30==29)
{
linecount++;
}
heading[count]=word;
count++;
}
else if(linecount==1)
{
u_line=word;
linecount=2;
}
//for every word both line and count is checked and value is inserted to the correspondin array
else if(linecount>1)
{
if(count%30==0)
{
f_name[linecount-2]=word;
  
}
else if(count%30==1)
{
l_name[linecount-2]=word;
}
else if(count%30>=2 && count%30<=11)
{
//string to float conversion
float x=std::stof(word);
q[linecount-2][q_index]=x;
q_index++;
}
else if(count%30>=12 && count%30<=21)
{
float x=std::stof(word);
l[linecount-2][l_index]=x;
l_index++;
}
else if(count%30>=22 && count%30<=24)
{
float x=std::stof(word);
p[linecount-2][p_index]=x;
p_index++;
}
else if(count%30>=25 && count%30<=27)
{
float x=std::stof(word);
e[linecount-2][e_index]=x;
e_index++;
}
else if(count%30==28)
{
float x=std::stof(word);
f[linecount-2]=x;
}
else if(count%30==29)
{
//count = 29 means the last word of the line hence line count is incremented
float x=std::stof(word);
att[linecount-2]=x;
l_index=0;
q_index=0;
p_index=0;
e_index=0;
linecount++;
}
count++;
}
}
f1.close();
//opens the next file in write mode
std::ofstream f2;
f2.open("letter120.dat");
//writes the headings to file
f2<<setw(25)<<left<<"First Name "<<setw(25)<<left<<"Last Name"<<setw(25)<<left<<"Final Grade"<<endl;
//displays headings for output window
cout<<setw(15)<<left<<"First Name "<<setw(15)<<left<<"Last Name"<<setw(15)<<left<<"Quiz Grade"
<<setw(15)<<left<<"Project Grade"<<setw(15)<<left<<"labs Grade"<<setw(15)<<left<<"Mid-term Grade"<<endl;
//function calling for each students details are done here
for(k=0;k<linecount-2;k++)
{

cout<<setw(15)<<left<<f_name[k]<<setw(15)<<left<<l_name[k]<<setw(15)<<left<<getGrade(getAverage(q,10))
<<setw(15)<<left<<getGrade(getAverage(p,3))<<setw(15)<<left<<getGrade(getAverage(l,10))<<setw(15)<<left<<getGrade(getAverage(e,3))<<endl;
//here final grade is calculated by adding all scores and finds its average then attendence is substracted
sum=getAverage(q,10)+getAverage(l,10)+getAverage(p,3)+getAverage(e,3)+f[k]-att[k];
  
f2<<setw(25)<<left<<f_name[k]<<setw(25)<<left<<l_name[k]<<setw(25)<<left<<getGrade(sum/5)<<std::endl;

}
f2.close();
return 0;
}

float getAverage(float gradeArray[][50],int n )
{
float a_sum=0;
for(int i=0;i<n;i++)
{
a_sum=a_sum+gradeArray[k][i];
}
return (a_sum/n);
}
char getGrade(float num)
{
if(num>=90 && num <=100)
return 'A';
else if(num>=80 && num<=89)
return 'B';
else if(num>=70 && num<=79)
return 'C';
else if(num>=60 && num<=69)
return 'D';
else if(num>=50 && num<=59)
return 'E';
else if(num>=49)
return 'F';
}

OUTPUT

First Name Last Name Quiz Grade Project Grade labs Grade Mid-term Grade
Kevin Smith A A A A
Morgan Kelly B A B D
Isaac Newton A A A A
Cole Jones B B B D
Angela Allen A B A C
David Cooper C B B C
Nancy Bailey A A A A
Emily Synder D B C B
Lori Austin A A A A
Jenny Howard D D F D
Anne Lewis C F C B
Nick Johnson B A A C
Nick Spickler A A A A
Joy Williams D A B B
Barbara Hood F C B A
Joe Hoarn D B B C
Payton Bardzell A A A B
Kim Ludwig D B C A
Susan Honks A F A A


OUTPUT FILE

First Name Last Name Final Grade
Kevin Smith A
Morgan Kelly B
Isaac Newton A
Cole Jones C
Angela Allen B
David Cooper B
Nancy Bailey A
Emily Synder F
Lori Austin A
Jenny Howard C
Anne Lewis C
Nick Johnson A
Nick Spickler A
Joy Williams B
Barbara Hood B
Joe Hoarn C
Payton Bardzell A
Kim Ludwig B
Susan Honks A


Related Solutions

First Last Q0 Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q8 Q9 L0 L1 L2 L3...
First Last Q0 Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q8 Q9 L0 L1 L2 L3 L4 L5 L6 L7 L8 L9 P0 P1 P2 E0 E1 E2 FI ATT ------------------------------------------------------------------------------------------------------------------------------------------ Kevin Smith 90 100 100 100 98 97 87 100 85 87 89 100 100 100 100 90 100 98 90 100 98 98 98 90 90 98 88 0.00 Morgan Kelly 80 100 65 67 69 71 100 100 100 67 95 85 87 89 100 65 67...
Do all the Q1, Q2, Q3 and Q4 The cash budget is the primary tool used...
Do all the Q1, Q2, Q3 and Q4 The cash budget is the primary tool used in short-term financial planning. As with many calculations, the sales forecast is a primary input. As an example of the cash budgeting process, we will use the Fun Toys Corporation. The sales projections and other information provided are: Q1 Q2 Q3 Q4 Sales $    200,000,000 $      300,000,000 $    250,000,000 $    400,000,000 Beginning receivables: $    120,000,000 Receivables period (days):                        45 With the receivables period shown, we can calculate the percentage...
Production Budget Q1 Q2 Q3 Q4 Total Sales in Units        1,000        1,200        1,500...
Production Budget Q1 Q2 Q3 Q4 Total Sales in Units        1,000        1,200        1,500        2,000        5,700 Add: Desired Ending Inv.                240            300            400            400            400 Total Needs        1,240        1,500        1,900        2,400        6,100 Less:Beginning Inv.                180            240            300            400            180 Units to be produced        1,060        1,260        1,600        2,000        5,92 The Direct Materials Budget tells management how much...
Brunell Products has projected the following sales for the coming year:    Q1 Q2 Q3 Q4...
Brunell Products has projected the following sales for the coming year:    Q1 Q2 Q3 Q4 Sales $480 $570 $720 $660    Sales in the year following this one are projected to be 10 percent greater in each quarter.    Calculate payments to suppliers assuming that the company places orders during each quarter equal to 25 percent of projected sales for the next quarter. Assume that the company pays immediately.    a. What is the payables period in this case?...
Let Q1, Q2, Q3, Q4 be constants so that R (2x + 3) sin 4x dx...
Let Q1, Q2, Q3, Q4 be constants so that R (2x + 3) sin 4x dx = (Q1x + Q2) sin 4x + (Q3x+Q4) cos 4x+C, where C is a constant of integration. Let Q = ln(3 +|Q1|+ 2|Q2|+ 3|Q3| + 4|Q4|). Then T = 5 sin2 (100Q) satisfies:— (A) 0 ≤ T < 1. — (B) 1 ≤ T < 2. — (C) 2 ≤ T < 3. — (D) 3 ≤ T < 4. — (E) 4 ≤...
Wentworth Products has projected the following sales for the coming year: Q1 Q2 Q3 Q4   Sales...
Wentworth Products has projected the following sales for the coming year: Q1 Q2 Q3 Q4   Sales $360 $450 $600 $540 Sales in the year following this one are projected to be 10 percent greater in each quarter. Calculate payments to suppliers assuming that the company places orders during each quarter equal to 25 percent of projected sales for the next quarter. Assume that the company pays immediately. a. What is the payables period in this case? (Do not round intermediate...
Wentworth Products has projected the following sales for the coming year: Q1 Q2 Q3 Q4   Sales...
Wentworth Products has projected the following sales for the coming year: Q1 Q2 Q3 Q4   Sales $650 $740 $875 $805 Sales in the year following this one are projected to be 15 percent greater in each quarter. a. Assume that the company places orders during each quarter equal to 30 percent of projected sales for the next quarter. Assuming that the company pays immediately, what is the payables period? (Do not round intermediate calculations and round your answer to the...
All That Remains Products has projected sales for next year of: Q1 Q2 Q3 Q4 Sales...
All That Remains Products has projected sales for next year of: Q1 Q2 Q3 Q4 Sales $ 76,000 $ 79,775 $ 86,500 $ 93,480 The company places orders each quarter that are 52 percent of the following quarter's sales and has a 60-day payables period. What is the accounts payable balance at the end of the third quarter?
Direct Materials Budget For the year ending December 31, 2018 Plain t-shirts Q1 Q2 Q3 Q4...
Direct Materials Budget For the year ending December 31, 2018 Plain t-shirts Q1 Q2 Q3 Q4 Total Units to be produced 1060 1260 1600 2000 5920 Direct materials per unit 1 1 1 1 1 Production needs 1060 1260 1600 2000 5920 Desired ending inventory 126 160 200 106 106 Total needs 1186 1420 1800 2106 6026 Less beginning inventory 58 126 160 200 58 Direct materials to be purchased 1128 1294 1640 1906 5968 Cost per t-shirt $       3.00...
Period Sales ($million) 2017 Q1 2874 2017 Q2 3000 2017 Q3 2913 2017 Q4 2916 2918...
Period Sales ($million) 2017 Q1 2874 2017 Q2 3000 2017 Q3 2913 2017 Q4 2916 2918 Q1 2910 2018 Q2 3052 2018 Q3 3116 2018 Q4 3210 2019 Q1 3243 2019 Q2 3351 2019 Q3 3305 2019 Q4 3267 The above table represents the quarterly sales (measured in millions of dollars) for the Goodyear Tire from 2017 to 2019. Compute the 4-quarter moving average. Put your answers onto the table. Compute the 4-quarter centered moving average. Put your answers onto...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT