Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello I need help fixing my C++ code. I need to display in the console the information saved in the file as well have the

Hello I need help fixing my C++ code. I need to display in the console the information saved in the file as well have the content saved in the file output in a fixed position like the screenshot. Thanks.

CODE

#include #include #include

using namespace std;

//main function int main() { //variable to store student id int id; //variables to store old gpa(ogpa), old course credits(occ), new course credits(ncc), current gpa(cur_gpa), cumulative gpa(cum_gpa) float ogpa, occ, ncc, cur_gpa, cum_gpa; //variables to store course credits float c1, c2, c3, c4; //variables to store grades float g1, g2, g3, g4; //variables to store old honor points and new honor points float ohp, nhp; //variables for input file name and output file name char in_file_name[100],out_file_name[100]; //objects for read from file and write to file ifstream in_stream; ofstream out_stream; //prompt for input file name cout > in_file_name; //prompt for output file name cout > out_file_name; //opening input file in_stream.open(in_file_name); //reading student id, old gpa, old course credits in_stream >> id >> ogpa >> occ; //reading course credits in_stream >> c1 >> c2 >> c3 >> c4; //reading grades in_stream >> g1 >> g2 >> g3 >> g4; //calculating old honor points ohp = occ * ogpa; //calculating new honor points nhp = (c1 * g1) + (c2 * g2) + (c3 * g3) + (c4 * g4); //calculating new course credits ncc = c1 + c2 + c3 + c4; //calculating current gpa cur_gpa = nhp / ncc; //calculating cumulative gpa cum_gpa = (nhp + ohp) / (ncc + occ); //opening output file out_stream.open(out_file_name); //writing student id to file out_stream

Screenshot:

image text in transcribed

All outputs should be written to an output file which has a format exactly like the following. Student ID number: 213141 Previous semesters' credit: Previous semesters' GPA: GPA of current semester: Cumulative GPA: Total credits completed

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

Recommended Textbook for

More Books

Students also viewed these Databases questions