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, 23.06.2019 03:00
What are the different parts of computer
Answers: 2
question
Computers and Technology, 23.06.2019 14:30
Open this link after reading about ana's situation. complete each sentence using the drop-downs. ana would need a minimum of ato work as a translator. according to job outlook information, the number of jobs for translators willin the future.
Answers: 3
question
Computers and Technology, 24.06.2019 00:00
Which tool could be used to display only rows containing presidents who served two terms
Answers: 3
question
Computers and Technology, 24.06.2019 00:50
Which of the following is not a key player in the sale of travel products?
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