#include <iostream>
using namespace std;
const int NUM_OF_STUDENTS = 7;
/*
a 1 business
b 1 computer
c 2 business
d 3 economics
e 4 bla
f 5 mechanics
g 99 statistics
1
*/
//unknown is defined as 5
enum Department {business, computer, economics, mechanics,
statistics, unknown};
void get_name(int index, string name, string
(&names)[NUM_OF_STUDENTS]) {
names[index] = name;
}
void get_score(int index, double score, double
(&scores)[NUM_OF_STUDENTS]) {
scores[index] = score;
}
void get_department(int index, string department, int
(&departments)[NUM_OF_STUDENTS]) {
if (department == "business")
departments[index] = business;
else if (department == "computer")
departments[index] = computer;
else if (department == "economics")
departments[index] = economics;
else if (department == "mechanics")
departments[index] = mechanics;
else if (department == "statistics")
departments[index] = statistics;
else
departments[index] = unknown;
}
void total_information(string names[NUM_OF_STUDENTS], double
scores[NUM_OF_STUDENTS], int departments[NUM_OF_STUDENTS]) {
for (int i = 0; i < NUM_OF_STUDENTS; i++) {
cout << "Student " << names[i] << " : " <<
"Score _ " << scores[i] << " Department _ " <<
departments[i] << endl;
}
}
void average_by_dept(int codeNumber, double
scores[NUM_OF_STUDENTS], int departments[NUM_OF_STUDENTS]) {
double average;
double sum = 0;
int cnt = 0;
for (int i = 0; i < NUM_OF_STUDENTS; i++) {
if (departments[i] == codeNumber) {
sum += scores[i];
cnt++;
}
}
average = sum / (double)cnt;
cout << "Average of department " << codeNumber <<
" scores is : " << average << endl;
cout << "Sum of department " << codeNumber << "
scores is : " << sum << endl;
}
int main()
{
string names[NUM_OF_STUDENTS];
double scores[NUM_OF_STUDENTS];
int departments[NUM_OF_STUDENTS];
cout << "Input NUM_OF_STUDENTS students' information : "
<< endl;
//Store information
for (int i = 0; i < NUM_OF_STUDENTS; i++) {
string name;
double score;
string department;
cin >> name >> score >> department;
get_name(i, name, names);
get_score(i, score, scores);
get_department(i, department, departments);
}
while (true) {
cout << "Input your choice : ";
int choice;
cin >> choice;
cout << endl;
if (choice == 1) {
total_information(names, scores, departments);
}
else if (choice == 2) {
cout << "Input department name : ";
string department;
cin >> department;
cout << endl;
int codeNumber;
if (department == "business")
codeNumber = business;
else if (department == "computer")
codeNumber = computer;
else if (department == "economics")
codeNumber = economics;
else if (department == "mechanics")
codeNumber = mechanics;
else if (department == "statistics")
codeNumber = statistics;
else
codeNumber = unknown;
average_by_dept(codeNumber, scores, departments);
}
else {
break;
}
}
return 0;
}
comment down for any queries
please give a thumbs up
C++ please use only easy code and stdio.h because im just a beginner Description Write the...
Write this code on python 3 only. Suppose class Student represents information about students in a course. Each student has a name and a list of test scores. The Student class should allow the user to view a student's name, view a test score at a given position, view the highest test score, view the average test score, and obtain a string representation of the student's information. When a Student object is created, the user supplies the student's name and...
Write a complete C++ program that reads students names and their test scores from an input text file. The program should output each student’s name followed by the test scores and the relevant grade in an output text file. It should also find and display on screen the highest/lowest test score and the name of the students having the highest/lowest test score, average and variance of all test scores. Student data obtained from the input text file should be stored...
PLEASE USE BASIC C++ CODE PLEASE USE BASIC C++ CODE PLEASE HAVE DONE AS SOON AS POSSIBLE THANK YOU I REALLY APPRECIATE IT FILE TEXT: Mary 80 90 75 90 85 Joe 80 65 80 80 80 Same program as Quiz #4, but this time it must be done with arrays: Write a program that calculates the average of 5 test scores for each student on the file. Function 1--write a function to read the student's name 5 test scores...
write a C progam not C++ please include comments im a beginner During a drawing competition, the review system is implemented by assigning 3 to 5 reviewers per submission. Each drawing is ranked by 3 to 5 reviewers on a continuous scale of 1 to 5 (1 being the lowest score and 5 being the highest, decimal numbers are not allowed). Final results are saved in the reviews file (given separately). (Format of each line: author_name,score_Iscore_2............score 5) James,24152 Ann, 145...
Write a class called Student. The specification for a Student is: Three Instance fields name - a String of the student's full name totalQuizScore - double numQuizesTaken - int Constructor Default construtor that sets the instance fields to a default value Parameterized constructor that sets the name instance field to a parameter value and set the other instance fields to a default value. Methods setName - sets or changes the student name by taking in a parameter getName - returns...
Given a score file named as scores.txt, the named file is posted alone side with the assignment. The score file has two part: first line is number of students and the rest is a list of names with scores. For example: 3 Tommy 35.5 John 77.2 David 59.4 The first function should be named as getScore and it takes a string parameter as input that is a student’s name, you then open the given score file, read the contents and return the student’s score stored in...
convert pseducode to c++ Starting out with Programming Logic and Design (3) - Read-only Terates once for each student. The nested inner loop, in lines 27 through 31, iterates once for each test score. Program 5-20 1 1 This program averages test scores. It asks the user for th 2 1/ number of students and the number of test scores per stude Declare Integer numStudents 4 Declare Integer numTest Scores 5 Declare Integer total 6 Declare Integer student 7 Declare...
Your assignment is to write a grade book for a teacher. The teacher has a text file, which includes student's names, and students test grades. There are four test scores for each student. Here is an example of such a file: Count: 5 Sally 78.0 84.0 79.0 86.0 Rachel 68.0 76.0 87.0 76.0 Melba 87.0 78.0 98.0 88.0 Grace 76.0 67.0 89.0 0.0 Lisa 68.0 76.0 65.0 87.0 The first line of the file will indicate the number of students...
#ifndef STUDENTTESTSCORES_H #define STUDENTTESTSCORES_H #include <string> using namespace std; const double DEFAULT_SCORE = 0.0; class StudentTestScores { private: string studentName; // The student's name double *testScores; // Points to array of test scores int numTestScores; // Number of test scores // Private member function to create an // array of test scores. void createTestScoresArray(int size) { numTestScores = size; testScores = new double[size]; for (int i = 0; i < size; i++) testScores[i] = DEFAULT_SCORE; } public: // Constructor StudentTestScores(string...
ANY HELP PLEASE. PLEASE READ THE WHOLE INSTRUCTION THANK YOU Write a program GS.java that will be responsible for reading in the names and grades for a group of students, then reporting some statistics about those grades. The statistics to be gathered are the number of scores entered, the highest score and the name(s) of the student(s) who earned that score, the lowest score and the name(s) of the student(s) who earned that score, and the average score for the...