Computers and Technology
Computers and Technology, 28.11.2020 22:30, delayne22

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

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 11:20, destinyleisantos
The kurt vonnegut commencement speech, the neiman-marcus chocolate chip cookie recipe, and the get-well emails to the dying boy are examples of select one: a. social engineering b. hoax emails c. email viruses d. worms
Answers: 1
image
Computers and Technology, 22.06.2019 16:00, raizagisselle1273
If a client wants to make minor edits, what should he/she use?
Answers: 3
image
Computers and Technology, 23.06.2019 16:00, lokaranjan5736
Write a grading program for a class with the following grading policies: a. there are two quizzes, each graded on the basis of 10 points. b. there is one midterm exam and one final exam, each graded on the basis of 100 points. c. the final exam counts for 50% of the grade, the midterm counts for 25%, and the two quizzes together count for a total of 25%. (do not forget to normalize the quiz scores. they should be converted to a percentage before they are averaged in.) any grade of 90 or more is an a, any grade of 80 or more (but less than 90) is a b, any grade of 70 or more (but less than 80) is a c, any grade of 60 or more (but less than 70) is a d, and any grade below 60 is an f. the program will read in the student’s scores and output the student’s record, which consists of two quiz and two exam scores as well as the student’s average numeric score for the entire course and final letter grade. define and use a structure for the student reco
Answers: 2
image
Computers and Technology, 24.06.2019 02:20, isabelsmhl
Peter is thinking of a number which isless than 50. the number has 9 factors. when he adds 4 to the number, itbecomes a multiple of 5. what is thenumber he is thinking of ?
Answers: 1
Do you know the correct 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 in other subjects:

Konu
Physics, 22.07.2019 20:30
Konu
Mathematics, 22.07.2019 20:30