subject

C++ Code Outputs. I have a problem with my code and I don't know how to make it run as the project that I need below.

This is my code:

#include

#include

#include

#include

using namespace std;

struct courseInfo{

string name;

int unit;

char grade;

};

struct Student {

string fName;

string lName;

string idNumber;

courseInfo courses[2];

int unitCompleted;

double gpa;

};

Student s;

bool openFile(ifstream &in);

void Print_info_one(Student s);

void Read_info(Student &s);

float Find_points(char c) ;

bool openFile(ifstream &inFile){

string line;

int i=0,k=0;

string fName="", lname="", id="", name1="", name2="";

char grade1, grade2;

int unit1, unit2;

if (inFile. is_open())

{

while (getline(inFile, line))

{

while (line[i] != ',')

{

fName += line[i];

i++;

}

i++;

i++;

while (line[i] != ' ')

{

lname += line[i];

i++;

}

i++;i++;

while (line[i] != ' ')

{

id += line[i];

i++;

}

i++;

int count=0;

while (count <2)

{

name1 += line[i];

i++;

if(line[i] == ' ' ) count++;

}

i++;

grade1 = line[i];

i++;i++;

unit1 = line[i]-'0';

i++;i++;

count=0;

while (count <2)

{

name2 += line[i];

i++;

if(line[i] == ' ' ) count++;

}

i++;

grade2 = line[i];

i++;i++;

unit2 = line[i]-'0';

}

inFile. close();

s. fName = fName;

s. lName = lname;

s. idNumber = id;

s. courses[0].name = name1;

s. courses[0].grade = grade1;

s. courses[0].unit = unit1;

s. courses[1].name = name2;

s. courses[1].grade = grade2;

s. courses[1].unit = unit2;

s. unitCompleted = unit1 + unit2;

s. gpa = (unit1*Find_points(grade1) + unit2*Find_points(grade2))/(unit1+u nit2);

}

else

{

cout << "Error reading file\n";

return false;

}

return true;

}

void Print_info_one(Student s){

cout << "Name: " << s. fName << ", " << s. lName << " ID Number: " << s. idNumber << " Course 1 Name: " << s. courses[0].name << " Grade: "

<< s. courses[0].grade << " Units: " << s. courses[0].unit << " Course 2 Name: " << s. courses[1].name << " Grade: "

<< s. courses[1].grade << " Units: " << s. courses[1].unit << " Unit completed: " << s. unitCompleted << " GPA:" << s. gpa << endl;

}

void Read_info(Student &s){

}

float Find_points(char grade){

switch (grade)

{

case 'A':

return 4.0;

break;

case 'B':

return 3.0;

break;

case 'C':

return 2.0;

break;

case 'D':

return 1.0;

break;

case 'F':

return 0;

break;

default:

break;

}

return 0;

}

int main() {

ifstream inFile;

std::fstream fs;

fs. open ("input. txt", std::fstream::in );

Print_info_one(s);

return 0;

}
In the screenshots i'm showing the inputs and outputs that I need for the test


C++ Code Outputs.

I have a problem with my code and I don't know how to make it run as the projec
C++ Code Outputs.

I have a problem with my code and I don't know how to make it run as the projec
C++ Code Outputs.

I have a problem with my code and I don't know how to make it run as the projec
C++ Code Outputs.

I have a problem with my code and I don't know how to make it run as the projec

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 18:00
When is it appropriate to use an absolute reference
Answers: 1
question
Computers and Technology, 22.06.2019 20:00
What statement best describes operating systems? it’s possible for modern computers to function without operating systems. most operating systems are free or very inexpensive. operating systems are managed by the computer’s microprocessor (cpu). operating systems manage the computer’s random access memory (ram).
Answers: 1
question
Computers and Technology, 23.06.2019 01:00
Write the command that can be used to answer the following questions. (hint: try each out on the system to check your results.) a. find all files on the system that have the word test" as part of their filename. b. search the path variable for the pathname to the awk command. c. find all files in the /usr directory and subdirectories that are larger than 50 kilobytes in size. d. find all files in the /usr directory and subdirectories that are less than 70 kilobytes in size. e. find all files in the / directory and subdirectories that are symbolic links. f. find all files in the /var directory and subdirectories that were accessed less than 60 minutes ago. g. find all files in the /var directory and subdirectories that were accessed less than six days ago. h. find all files in the /home directory and subdirectories that are empty. i. find all files in the /etc directory and subdirectories that are owned by the group bin."
Answers: 1
question
Computers and Technology, 23.06.2019 03:30
How can you repin an image on your pinterest pin board a. click on the "repin" button b. click on the "add pin" button c. click on the "upload a pin" button d. click on the "save pin" button.
Answers: 2
You know the right answer?
C++ Code Outputs. I have a problem with my code and I don't know how to make it run as the project...
Questions
question
Mathematics, 14.04.2021 05:10
question
Mathematics, 14.04.2021 05:10
question
Chemistry, 14.04.2021 05:10
question
Social Studies, 14.04.2021 05:10
Questions on the website: 13722359