C++ Homework Help:
The text file that it wants you to download is this:
Name: Peter Parker
CSCI-261: 95
CSCI-262: 90.625
CSCI-442: 91.20
Name: Mary Smith
CSCI-442: 65.0
CSCI-562: 79.1234
CSCI-580: 70.24
Name: Pat Brown
CSCI-562: 95
CSCI-565: 88.0
CSCI-580: 91.20
Name: Linda Williams
CSCI-262: 65.0
CSCI-306: 67.719
CSCI-562: 70.200
Name: John Miller
CSCI-261: 95.281
CSCI-306: 90.625
CSCI-565: 91.20
Name: Patricia Johnson
CSCI-306: 65.012
CSCI-442: 84.76
CSCI-580: 70
Name: Brian Hall
CSCI-261: 65.0
CSCI-306: 84.712
CSCI-442: 75.24
Name: Sandra Nelson
CSCI-262: 95.281
CSCI-306: 90.625
CSCI-565: 91.20
Name: Jason Baker
CSCI-261: 65.012
CSCI-306: 84.76
CSCI-442: 70
Name: Gary Carter
CSCI-562: 65.0
CSCI-565: 84.712
CSCI-580: 75.24
Code
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include <numeric>
#include<iomanip>
using namespace std;
int getCourseNumberIndex(string course);
int main()
{
ifstream inFile;
ofstream outFile;
inFile.open("grades.txt");
outFile.open("output.txt");
if(!inFile)
{
cout<<"Unable to open the
file! Exiting......"<<endl;
return 1;
}
string firstName,lastName,subject,name,subName;
int underGraduateCount=0,graduateCount=0;
double mark;
vector<double>score;
int subCount[]={0,0,0,0,0,0,0},index;
string courses[]={"CSCI 261: Programing
Concepts","CSCI-262: Data Structure","CSCI-262: Software
Engineering","CSCI-262: Operating System","CSCI-262: Applied
ALgoritham & Data Structures","CSCI-262: Distributed Computing
System","CSCI-262: Advanced High Performance Computing"};
outFile << fixed << setprecision(2)
;
while(inFile>>name>>firstName>>lastName)
{
inFile>>subName>>mark;
index=getCourseNumberIndex(subName);
subCount[index]+=1;
if(index<4)
underGraduateCount++;
else
graduateCount++;
score.push_back(mark);
inFile>>subName>>mark;
index=getCourseNumberIndex(subName);
if(index<4)
underGraduateCount++;
else
graduateCount++;
subCount[index]+=1;
score.push_back(mark);
inFile>>subName>>mark;
index=getCourseNumberIndex(subName);
subCount[index]+=1;
if(index<4)
underGraduateCount++;
else
graduateCount++;
score.push_back(mark);
double average = accumulate(
score.begin(), score.end(), 0.0)/score.size();
score.clear();
outFile<<"Name:
"<<lastName<<", "<<firstName<<endl;
outFile<<"Average Score:
"<<average<<endl<<endl;
}
inFile.close();
outFile<<"There are
"<<underGraduateCount<<" instance of students taking
undergraduate level courses."<<endl;
outFile<<"There are
"<<underGraduateCount<<" instance of students taking
graduate level courses."<<endl<<endl;
for(int i=0;i<7;i++)
{
outFile<<courses[i]<<"
has "<<subCount[i]<<" students."<<endl;
}
outFile.close();
return 1;
}
int getCourseNumberIndex(string course)
{
if(course=="CSCI-261:")
return 0;
else if(course=="CSCI-262:")
return 1;
else if(course=="CSCI-306:")
return 2;
else if(course=="CSCI-442:")
return 3;
else if(course=="CSCI-562:")
return 4;
else if(course=="CSCI-565:")
return 5;
else if(course=="CSCI-580:")
return 6;
}
output
output.txt
If you have any query regarding the code please ask me in the comment i am here for help you. Please do not direct thumbs down just ask if you have any query. And if you like my work then please appreciates with up vote. Thank You.
C++ Homework Help: The text file that it wants you to download is this: Name: Peter...
In C++ Write a menu driven C++ program to read a file containing information for a list of Students, process the data, then present a menu to the user, and at the end print a final report shown below. You may(should) use the structures you developed for the previous assignment to make it easier to complete this assignment, but it is not required. Required Menu Operations are: Read Students’ data from a file to update the list (refer to sample...
C++ A professor plans to store the following data for each of his students: Last Name, First Name, Class Average (as a double), Letter Grade (“A”, “A-“, “B+”, “B”, etc.) Write two programs for writing and reading such a file, with the user choosing the file name. Store the (int) number of students as the first data value in the file, followed by \n. Then use the following delimiter scheme: Last Name(comma)First Name(comma)Average(space)Letter Grade(newline) For the file writer program, input...
Problem Specification:Write a C++ program to calculate student’s GPA for the semester in your class. For each student,the program should accept a student’s name, ID number and the number of courses he/she istaking, then for each course the following data is needed the course number a string e.g. BU 101 course credits “an integer” grade received for the course “a character”.The program should display each student’s information and their courses information. It shouldalso display the GPA for the semester. The...
(C++ programming) Need help with homework. Write a program that can be used to gather statistical data about the number of hours per week college students play video games. The program should perform the following steps: 1). Read data from the input file into a dynamically allocated array. The first number in the input file, n, represents the number of students that were surveyed. First read this number then use it to dynamically allocate an array of n integers. On...
Using C programming For this project, you have been tasked to read a text file with student grades and perform several operations with them. First, you must read the file, loading the student records. Each record (line) contains the student’s identification number and then four of the student’s numerical test grades. Your application should find the average of the four grades and insert them into the same array as the id number and four grades. I suggest using a 5th...
Hello I need help fixing my C++ code. I need to display in the console the information saved in the file as well have the content saved in the file output in a fixed position like the screenshot. Thanks. CODE #include<iostream> #include<fstream> #include<iomanip> using namespace std; //main function int main() { //variable to store student id int id; //variables to store old gpa(ogpa), old course credits(occ), new course credits(ncc), current gpa(cur_gpa), cumulative gpa(cum_gpa) float ogpa,...
Declare and initialize 4 Constants for the course category weights: The weight of Homework will be 15% The weight of Tests will be 35% The weight of the Mid term will be 20% The weight of the Fin al will be 30% Remember to name your Constants according to Java standards. Declare a variable to store the input for the number of homework scores and use a Scanner method to read the value from the Console. Declare two variables: one...
C++ Redo PROG8, a previous program using functions and/or arrays. Complete as many levels as you can. Level 1: (20 points) Write FUNCTIONS for each of the following: a) Validate #students, #scores. b) Compute letter grade based on average. c) Display student letter grade. d) Display course average. Level 2: (15 points) Use ARRAYS for each of the following. e) Read a student's scores into array. f) Calculate the student's average based on scores in array. g) Display the student's...
need help on C++ Discussion: The program should utilize 3 files. player.txt – Player name data file – It has: player ID, player first name, middle initial, last name soccer.txt – Player information file – It has: player ID, goals scored, number of penalties, jersey number output file - formatted according to the example provided later in this assignment a) Define a struct to hold the information for a person storing first name, middle initial, and last name). b) Define...
Files given in this assignment (right-click on the file to download) Assignment7.cpp (need to complete) Student.h (Given. Just use it, don't change it!) Student.cpp (Partially filled, need to complete) 1. Assignment description In this assignment, you will write a simple class roster management system for ASU CSE100. Step #1: First, you will need to finish the design of class Student. See the following UML diagram for Student class, the relevant header file (class declaration) is given to you as Student.h,...