Question

I need to write a program in c++ Suppose a teacher weights four exams. He gives...

I need to write a program in c++

Suppose a teacher weights four exams. He gives 10%, 25%, 30%, and 35%.

Write a program that reads ten sets of four grades, prints the weighted average of each set, and prints the unweighted average of each test. The number of students should be in a global constant.

Please help. Thank you

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <iostream>
#include <string>
using namespace std;
int NUM = 2;
int main()
{

int student[NUM][4];
cout<<"Enter marks for: "<<NUM <<" students "<<endl;
for(int i=0;i<NUM;++i){
   for(int j=0;j<4;++j){
       cin>>student[i][j];
       if(j==0){
           student[i][j] = student[i][j]*0.1;
       }else if(j==1){
           student[i][j] = student[i][j]*0.25;
       }else if(j==2){
           student[i][j] = student[i][j]*0.3;
       }else{
           student[i][j] = student[i][j]*0.35;
       }
    }  
}

    double average = 0;
   for(int i=0;i<NUM;++i){
       average = 0;
   for(int j=0;j<4;++j){
       average = average + student[i][j];
    }
    cout<<"\nWeighted average of student "<<(i+1)<<": "<<average/4;
}
}



===========================
See Output

1 #include <iostream> 2 3 using namespace std; 4 int NUM -2; 5 int mainO #include <string» 7 int student [NUM] [4]; cout<< E

Thanks, let me know if there is any concern.

Add a comment
Know the answer?
Add Answer to:
I need to write a program in c++ Suppose a teacher weights four exams. He gives...
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
  • C++ Write a program that reads the number of students in the class, then reads each...

    C++ Write a program that reads the number of students in the class, then reads each student's name and his/her test score. Print out each student name, test score and grade, and the average score of the whole class. The program must use vectors and loops for the implementation. The grades are determined as follows: A >= 90; 80 <= B < 90; 70 <= C < 80; 60 <= D < 70; F < 60.

  • This is a C++ Program, I need the program broken up into Student.h, Student.cpp, GradeBook.h, GradeBook.cpp,...

    This is a C++ Program, I need the program broken up into Student.h, Student.cpp, GradeBook.h, GradeBook.cpp, and Main.cpp 1. The system must be able to manage multiple students (max of 5) and their grades for assignments from three different assignment groups: homework (total of 5), quizzes (total (total of 2) of 4), and exams 2. For each student record, the user should be able to change the grade for any assignment These grades should be accessible to the gradebook for...

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

  • Language: C++ Write a program that will allow the instructor to enter the student's names, student...

    Language: C++ Write a program that will allow the instructor to enter the student's names, student ID, and their scores on the various exams and projects. A class has a number of students during a semester. Those students take 4 quizzes, one midterm, and one final project. All quizzes weights add up to 40% of the overall grade. The midterm exam is 25% while the final project 35%. The program will issue a report. The report will show individual grades...

  • You must assume that the data file and your four function subprograms are located inside the working directory (forder). Please write the main program and each of the four function subprograms. 1. Th...

    You must assume that the data file and your four function subprograms are located inside the working directory (forder). Please write the main program and each of the four function subprograms. 1. The data in the following table are to be read from the file "grades.txt"and processed The grades are in percentages. The format of the data is shown below First Name ID Number Last Name Grades 001AA Tam 78.50 oe 86.45 001AB Gabriel Stuart Thus, there are 4 columns...

  • Consider the following program that reads students’ test scores into an array and prints the contents of the array. You will add more functions to the program. The instructions are given below.

    Consider the following program that reads students’ test scores into an array and prints the contents of the array.   You will add more functions to the program.  The instructions are given below.              For each of the following exercises, write a function and make the appropriate function call in main.Comments are to be added in the program. 1.       Write a void function to find the average test score for each student and store in an array studentAvgs. void AverageScores( const int scores[][MAX_TESTS],                       int...

  • Please help. I need a very simple code. For a CS 1 class. Write a program...

    Please help. I need a very simple code. For a CS 1 class. Write a program in Java and run it in BlueJ according to the following specifications: The program reads a text file with student records (first name, last name and grade). Then it prompts the user to enter a command, executes the command and loops. The commands are the following: "printall" - prints all student records (first name, last name, grade). "firstname name" - prints all students with...

  • Plz help!! The programming language is C and could you write comments as well? Problem 2....

    Plz help!! The programming language is C and could you write comments as well? Problem 2. Calculate Grades (35 points) Arrays can be used for any data type, such as int and char. But they can also be used for complex data types like structs. Structs can be simple, containing simple data types, but they can also contain more complex data types, such as another struct. So you could have a struct inside of a struct. This problem deals with...

  • c++ A menu-driven program gives the user the option to find statistics about different baseball players....

    c++ A menu-driven program gives the user the option to find statistics about different baseball players. The program reads from a file and stores the data for ten baseball players, including player’s team, name of player, number of homeruns, batting average, and runs batted in. (You can make up your data, or get it online, for example: http://espn.go.com/mlb/statistics ) Write a program that declares a struct to store the data for a player. Declare an array of 10 components to...

  • Write a C++ program that asks user number of students in a class and their names....

    Write a C++ program that asks user number of students in a class and their names. Number of students are limited to 100 maximum. Then, it will ask for 3 test scores of each student. The program will calculate the average of test scores for each student and display with their names. Then, it will sort the averages in descending order and display the sorted list with students’ names and ranking. Follow the Steps Below Save the project as A4_StudentRanking_yourname....

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