1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
RSB [31]
3 years ago
9

C++ Code Outputs.

Computers and Technology
1 answer:
mojhsa [17]3 years ago
5 0

Answer:

#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+unit2);

}

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;

Explanation:

You might be interested in
Excel has more than 400 additional functions that perform just about every type of calculation you can imagine. Answer
Blababa [14]
Im pretty sure the answer is True.
5 0
4 years ago
What is the purpose of the "time-to-live" (TTL) field of the IPv4 packet? a. ensures that the packet remains in the network long
Arisa [49]

Answer:

c. it prevents the packet from remaining indefinitely in the network thus helping to prevent network congestion

Explanation:

It prevents the packet from remaining indefinitely in the network thus helping to prevent network congestion

TTL is a value which is shown so that we can estimate that the packet that will tell the network router whether the packet has been in the network for enough time so that it should be discarded from the network or not.

6 0
3 years ago
ASAP!!!!!!!
Sidana [21]
A .2:)())...........\\
5 0
3 years ago
Read 2 more answers
Can someone help me on how to start this essay?
mezya [45]

Answer:

Start off with an interesting introduction (add questions) make it interesting.

6 0
3 years ago
Read 2 more answers
Trish has bought a new computer, which she plans to start working on after a week. Since Trish has not used computers in the pas
Elenna [48]
Go on the windows sign and type in run and then type temp and %temp% or prefetch
8 0
3 years ago
Read 2 more answers
Other questions:
  • Write a program to display a message telling the educational level of a student based on their number of years of school. The us
    6·1 answer
  • Max needs to study more effectively to get a better grade on his next exam. What can he do to improve his study habits? Check al
    10·2 answers
  • What the heck is a motherboard and why is my computer not working when i take it out
    14·1 answer
  • What is information associated with a document to help describe that document called?
    12·1 answer
  • Using a windows computer, to make a window wider, you would move the pointer until it changes to the horizontal resize shape and
    6·1 answer
  • What city, the major financial center of its country, is located on the northern coast of the island where the poet who wrote "A
    8·2 answers
  • Jeremy is working with a team that is creating an application using attributes and associated methods. What type of programming
    8·1 answer
  • Agent Phil Coulson developed this program to register Avengers in S.H.I.E.L.D's database using cutting-edge programming language
    15·1 answer
  • Adam is writing a program that: 1) has the user guess a number, and 2) tells the user how many guesses it took to get the correc
    9·2 answers
  • Is this statement true or false? While in slide show mode, if you are not careful you can close the application by clicking the
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!