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 10:00
According to alisa miller foreign news bureaus
Answers: 3
question
Computers and Technology, 22.06.2019 22:20
Avariable of the data type arrays is storing 10 quantities. what is true about these quantities? a. the quantities all have different characteristics. b. the quantities all have the same characteristics. c. five quantities have the same and five have different characteristics. d. it is necessary for all quantities to be integers. e. it is necessary for all quantities to be characters.
Answers: 2
question
Computers and Technology, 23.06.2019 12:00
Which of these is a benefit of using objects in a powerpoint presentation? a. collaborators can create the external files while you create and edit the slide show. b. you can easily change the theme and design of the presentation. c. you can have older data in the source file while having up-to-date data in the presentation. d. collaborators can easily share the presentation.
Answers: 2
question
Computers and Technology, 24.06.2019 07:00
Jean has kept the content of her website limited to what is important; she has also ensured that the text follows a particular style and color all throughout her website. which website features has jean kept in mind? jean has limited the content of her website to what is important; this ensures (clarity, simplicity, harmony and unity) of the content. she has also formatted the text in a particular style and color throughout her website, ensuring (balance, simplicity, consistency)
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, 18.02.2021 02:40
question
Mathematics, 18.02.2021 02:40
Questions on the website: 13722367