Question
C++
please use only easy code and stdio.h because im just a beginner
Description Write the program that can manage the information of students as follows: S 1. This program has two phase; the in
4. Define the functions for storing the information in the input phase as follows: (1) The function get name gets the student
Description Write the program that can manage the information of students as follows: S 1. This program has two phase; the input phase and the output phase. 2. In an input phase, a teacher inputs the information (name, score, and department) for each student. The total number of students who can be inputted should be defined as a NUM OF_STUDENT constant value. In this example, the value of NUM_OF_STUDENT is 7 3. The values of names, scores, and departments should satisfy the following requirements. (1) The names of students are the string values. The length of names is 19; in other words, you can enter 19 characters for a student's name at most. Assume that the name string does not have any white space such as a blank character (2) The scores of students are double type values. Obviously, the range of scores is [0, 1001, so it is okay if you don't check the validation of a user's input (3) The department is managed as an enumerated type. In the input phase, we focus on only 5 departments for the enumeration. Any other departments are considered as 'unknown (See the below for the departments with code numbers) department code number business 0 1 computer economics 2 mechanics 3 statistics 4 unknown other than 0-4 (4) All of these values should be located in a main function. Do NOT declare or assign them as global variables. Only the user-defined enumerated type for department code numbers can be defined outside of a main function.
4. Define the functions for storing the information in the input phase as follows: (1) The function get name gets the student's name. get name returns nothing but uses an array that stores the names of students as an output parameter (2) The function get score gets the student's score. get score returns nothing but uses an array that stores the scores of students as an output parameter (3) The function get_department has no parameter. This function takes an integer value as a user's input and returns it as a department code number. 5. After storing the information of all students, an output phase begins. There are two types of operations in the output phase; display all information, and display the average score by the department (1) Show total information when a user's input is 1. Meanwhile, compute the average score by the department if the user's input is 2 (2) Repeat the output phase during the user's input is 1 or 2. If the user enters other integer, the output phase ends and the whole program stops. 6. Define the functions for displaying the information in the output phase as follows: (1) The function total _information returns nothing. This function receives necessary data structures as parameters and displays the infomation of all students in the order in which they were entered. (See the screenshots for the details.) (2) The function average by_dept returns nothing. This function also receives necessary data structures as parameters. According to the department code number as a user's input, compute the average of students who are in that department. And, display the average with the number of students of that department and the total sum score of that department. (See the screenshots for the details.) (3) In the function average by dept, all the values of an average score, the number of students, and the total sum score are 0 if there is no student for the specific department whether the department code number is valid(0-4) or not. Likewise, the information of the department corresponding to the user's input code number should be calculated and displayed if there are one more students of the code number, even though the code number is invalid(less than 0 or greater than 4)
0 0
Add a comment Improve this question Transcribed image text
Answer #1

#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;
}

Input NUM_OF_STUDENTS students information a 1 business b 1 computer c 2 business -d 3 economics e 4 bla f 5 mechanics g 99

comment down for any queries

please give a thumbs up

Add a comment
Know the answer?
Add Answer to:
C++ please use only easy code and stdio.h because im just a beginner Description Write the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write this code on python 3 only. Suppose class Student represents information about students in a...

    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...

    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...

    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,...

    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 -...

    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...

  • c++ reading file that contains names and scores to compute averages, return scores when names are inputed and return if a students scores is aobve equal to or below the average

    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...

    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 includ...

    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...

    #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...

    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...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT