Question

In: Computer Science

C++ Visual Studio 2019 Part A : Program Description: Write a program to generate a report...

C++ Visual Studio 2019

Part A :

Program Description:

Write a program to generate a report based on input received from a text file. Suppose the input text file student_grades.txt contains the student’s Last name , First name, SSN, Test1, Test2, Test3 and Test4. (25%)

i.e.

Alfalfa   Aloysius   123-45-6789 40.0    90.0   100.0    83.0

Generate the output Report File student_final.txt in the following format :

LastName FirstName   SSN Test1   Test2   Test3   Test4 Average FinalGrade

i.e.

Alfalfa   Aloysius   123-45-6789 40.0    90.0   100.0    83.0    78.25 .0   C+

The program must be written to use the enum letterGrade :

enum letterGrade {A_PLUS,A, A_MINUS,B_PLUS,B, B_MINUS, C_PLUS,C, C_MINUS,D_PLUS,D, D_MINUS,F } ;

Use the following function prototype for deriving letter grade :

letterGrade deriveGrade(double average) ;

The average is calculated as follows : (test1 + test2 + test3 + test4)/4.0

The function deriveGrade should derive the letterGrade of the student based on the following grading scale :

Letter Grade

Percentage

GPA

A+

97%+

4.33/4.00 or 4.00/4.00

A

93%-96%

4.00/4.00

A-

90%-92%

3.67/4.00

B+

87%-89%

3.33/4.00

B

83%-86%

3.00/4.00

B-

80%-82%

2.67/4.00

C+

77%-79%

2.33/4.00

C

73%-76%

2.00/4.00

C-

70%-72%

1.67/4.00

D+

67%-69%

1.33/4.00

D

63%-66%

1.00/4.00

D-

60%-62%

0.67/4.00

F

0%-59%

0.00/4.00

Also provide the following function :

         string convertToText(letterGrade grade) ; //This function converts a letterGrade type to a string type.

Requirement :

  • The namespace ‘gradeOpt’ definition should contain the following members :(15%)
    1. the enum letterGrade definition,
    2. deriveGrade(..) function prototype and
    3. convertToText(…) function prototype
  • Add the namespace ‘gradeOpt ‘ to the grade.h header file and the namespace member function definitions to the file grade.cpp file. (10%)

Input text file student_grades.txt

Alfalfa   Aloysius   123-45-6789    90.0   100.0    83.0    49.0 
Alfred    Francis    123-12-1234    97.0    96.0    97.0    48.0 
Gerty     Gramma     567-89-0123    80.0    60.0    40.0    44.0
Android   Alexis     087-65-4321    23.0    36.0    45.0    47.0
Bumpkin   Fred       456-78-9012    78.0    88.0    77.0    45.0
Rubble    Betty      234-56-7890    90.0    80.0    90.0    46.0
Noshow    Cecil      345-67-8901    81.0    65.0     49.0   43.0
Buff      Bif        632-79-9939    20.0    30.0    40.0    50.0
Airpump   Andrew     223-45-6789    75.0    90.0    100.0   83.0
Backus    Jim        143-12-1234    85.0    97.0    96.0    97.0
Carnivore Art        565-89-0123    71.0    80.0    60.0    40.0
Dandy     Jim        087-75-4321    92.0    23.0    36.0    45.0
Elephant  Ima        456-71-9012    19.0    78.0    88.0    77.0
Franklin  Benny      234-56-2890    50.0    90.0    80.0    90.0
George    Boy        345-67-3901    40.0    11.0    91.0    84.0
Heffalump Harvey     632-79-9439    30.0    91.0    20.0    30.0

Solutions

Expert Solution

C++ Code:-

grade.hpp

namespace stdGrade{

enum letter_grade {A, A_PLUS, A_MINUS, B,B_PLUS, B_MINUS, C, C_PLUS, C_MINUS,D,D_PLUS,D_MINUS,F } ;

letter_grade deriveGrade(double average)

{

if(average>=97)

{

return A_PLUS;

}

else if(average>=93)

{

return A;

}

else if(average>=90)

{

return A_MINUS;

}

else if(average>=87)

{

return B_PLUS;

}

else if(average>=83)

{

return B;

}

else if(average>=80)

{

return B_MINUS;

}

else if(average>=77)

{

return C_PLUS;

}

else if(average>=73)

{

return C;

}

else if(average>=70)

{

return C_MINUS;

}

else if(average>=67)

{

return D_PLUS;

}

else if(average>=63)

{

return D;

}

else if(average>=60)

{

return D_MINUS;

}

else{

return F;

}

}

}

studentGrade.cpp

#include<iostream>

#include<fstream>

using namespace std;

#include "grade.hpp"

using namespace stdGrade;

string convertToText(letter_grade grade)

{

if(grade==A_PLUS)

return "A+";

else if(grade==A)

return "A";

else if(grade==A_MINUS)

return "A-";

else if(grade==B_PLUS)

return "B+";

else if(grade==B)

return "B";

else if(grade==B_MINUS)

return "B-";

else if(grade==C_PLUS)

return "C+";

else if(grade==C)

return "C";

else if(grade==C_MINUS)

return "C-";

else if(grade==D_PLUS)

return "D+";

else if(grade==D)

return "D";

else if(grade==D_MINUS)

return "D-";

else

return "F";

}

int main()

{

ifstream input;

input.open("student_grades.txt");

ofstream output;

output.open("student_final.txt");

string lname, fname, ssn, grd;

double t1, t2, t3, t4;

double average;

while(!input.eof())

{

input>>lname>>fname>>ssn;

input>>t1>>t2>>t3>>t4;

average=(t1+t2+t3+t4)/4;

letter_grade grade=deriveGrade(average);

grd=convertToText(grade);

//output to file

output<<lname<<" "<<fname<<" "<<ssn<<" "<<t1<<" "<<t2<<" "<<t3<<" "<<t4<<" "<<average<<" "<<grd<<endl;

}

//print a success message

cout<<"Successfully written to output file!"<<endl;

cin.get();

return 0;

}

ScreenShot:-

studentGrade.cpp

grade.hpp (please save this file as grade.hpp)

Output:-

Input File:-

Thank You....!!!!
For any query, please comment.
If you are satisfied with the above answer, then please thumbs up or upvote the answer.


Related Solutions

write a c++ program using micro soft visual studio 2010 to write a program and store...
write a c++ program using micro soft visual studio 2010 to write a program and store 36 in variable x and 8 in variable y. add them and store the result in the variable sum. then display the sum on screen with descriptive text. calculate the square root of integer 36 in x. store the result in a variable. calculate the cube root of integer 8 in y. store result in a variable. display the results of square root and...
String Manipulator Write a program to manipulate strings. (Visual Studio C++) In this program take a...
String Manipulator Write a program to manipulate strings. (Visual Studio C++) In this program take a whole paragraph with punctuations (up to 500 letters) either input from user, initialize or read from file and provide following functionalities within a class: a)   Declare class Paragraph_Analysis b)   Member Function: SearchWord (to search for a particular word) c)   Member Function: SearchLetter (to search for a particular letter) d)   Member Function: WordCount (to count total words) e)   Member Function: LetterCount (ONLY to count all...
Write a C-based language program in visual studio that uses an array of structs that stores...
Write a C-based language program in visual studio that uses an array of structs that stores student information including name, age, GPA as a float, and grade level as a string (e.g., “freshmen,”). Write the same program in the same language without using structs.
Code: please use in visual studio 2019 c++ (not java) In total you will write 6...
Code: please use in visual studio 2019 c++ (not java) In total you will write 6 functions: Functions : A ) addInts, returns int; input is two ints; Add the values of the two parameters and return the sum B) subInts , returns int; input is two ints; Subtract the values of the two parameters and return the difference C) multInts, returns int; input is two ints; multiple the values of the two parameters and return the product D) divInts,...
Write a C program The Visual Studio project itself must make its output to the Console...
Write a C program The Visual Studio project itself must make its output to the Console (i.e. the Command Prompt using printf) and it must exhibit the following features as a minimum: 3%: Looping Menu with 3 main actions: View Cars, Sell Car, View Sales Note: A Car is defined by its price and model 3%: Must contain at least three arrays to record sales figures (maximum of 10 Car models) Two for recording the price and model of one...
In visual Studio C++ Create a program that uses a for loop to input the high...
In visual Studio C++ Create a program that uses a for loop to input the high temperature, and low temperature for each day of the week. The high and low will be placed into two elements of the array. For each loop the high and low will be placed into the next set of elements of the array. After the temps for all seven days have been entered into the array, a for loop will be used to pull out...
Write a C program of car sale: The Visual Studio project itself must make its output...
Write a C program of car sale: The Visual Studio project itself must make its output to the Console (i.e. the Command Prompt using printf) and it must exhibit the following features as a minimum: 10%: Looping Menu with 2 main actions: Sell Car, View Sales Note: A Car is defined only by its price 10% Must contain at least one array containing sales figures (each entry represents the price of one vehicle) for a maximum of 10 Cars 5%:...
answer the following using C# Design and program a Visual Studio Console project in C# that...
answer the following using C# Design and program a Visual Studio Console project in C# that allows your user to enter a number. The program will examine the number to see if it is prime. If it is prime, it will print the next higher prime and the next lower primes to the console. If the number entered by the user is not prime, display a message to that effect. All code should be written by you. Do not copy/paste...
ONLY USE VISUAL STUDIO (NO JAVA CODING) VISUAL STUDIO -> C# -> CONSOLE APPLICATION In this...
ONLY USE VISUAL STUDIO (NO JAVA CODING) VISUAL STUDIO -> C# -> CONSOLE APPLICATION In this part of the assignment, you are required to create a C# Console Application project. The project name should be A3<FirstName><LastName>P2. For example, a student with first name John and Last name Smith would name the project A1JohnSmithP2. Write a C# (console) program to calculate the number of shipping labels that can be printed on a sheet of paper. This program will use a menu...
USING VISUAL STUDIO 2017, LANGUAGE VISUAL C# I have struggled on this program for quite some...
USING VISUAL STUDIO 2017, LANGUAGE VISUAL C# I have struggled on this program for quite some time and still can't quite figure it out. I'm creating an app that has 2 textboxes, 1 for inputting customer name, and the second for entering the number of tickets the customer wants to purchase. There are 3 listboxes, the first with the days of the week, the second with 4 different theaters, and the third listbox is to display the customer name, number...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT