Question

A professor has constructed a 3-by-4 two-dimensional array of float numbers. This array currently contains the...

A professor has constructed a 3-by-4 two-dimensional array of float numbers. This array currently contains the lab grades, quiz grades and exam grades of three students in the professor’s class. Write a C++ program that calculate the final grade for each student and save it to the last column. You program should display the following output: Lab Quiz ExamFinal Student 1 ## ## ## ## Student 2 ## ## ## ## Student 3 ## ## ## ## The final grade consists of 30% lab grade, 30% quiz grade and 40% exam. For example, if lab grade is 95, quiz grade is 82 and exam grade is 87, the final grade is equal to 95∗0.3+82∗0.3+87∗0.4. Use random numbers between 40 and 100 for lab, quiz and exam grades.

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

C++ CODE :-
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
float a[3][4] = {
{95, 82, 87, 0} , /* initializers for row indexed by 0 */
{96, 85, 86, 0} , /* initializers for row indexed by 1 */
{42, 55, 63, 0} /* initializers for row indexed by 2 */
};                        // 4th elements should be calculated
const char separator = ' '; // declaring constants for output allignment
const int nameWidth = 19;
const int numWidth = 18;
cout << right << setw(27) << setfill(separator) << "Lab"; // display table headings
cout << right << setw(nameWidth) << setfill(separator) << "Quiz";
cout << right << setw(nameWidth) << setfill(separator) << "Exam";
cout << right << setw(nameWidth) << setfill(separator) << "Final"<<endl;

for(int i=0;i<3;i++) // outer loop on rows
{
for(int j=0;j<3;j++) // inner loop on coloumns
{
if(j==0 || j==1) // if grades from lab or quiz ,dhould multiply with 0.3 i.e; 30%
{
a[i][j] = 0.3 * a[i][j];
}
else
a[i][j] = 0.4 * a[i][j]; // if grade from exam ,dhould multiply with 0.4 i.e; 40%

a[i][3] = a[i][3] + a[i][j]; // computing 4th element ie; final
}
}
for(int i=0;i<3;i++) // display scores in table format
{
cout <<left << setfill(separator) << "student :"<<(i+1) ;
for(int j=0;j<4;j++)
{
cout << right << setw(numWidth) << setfill(separator) << a[i][j];
}
cout<<endl;
}
cout << endl;
return 0;
}


OUTPUT :-

Add a comment
Know the answer?
Add Answer to:
A professor has constructed a 3-by-4 two-dimensional array of float numbers. This array currently contains 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
  • CSC888 has 4 people. Each person needs to take 3 tests. Create a 4-by-3 two-dimensional array...

    CSC888 has 4 people. Each person needs to take 3 tests. Create a 4-by-3 two-dimensional array to store the test scores. Ask the user to enter test scores one at a time to populate this array. Once the whole array is filled, do the following two things. (1) For each student, display her test scores and the average of the three tests. (2) For each test, display student scores and the average of the four students. The following shows a...

  • In C Langage Write a grading program for a class with the following grading policies:- a. There are two quizzes, each gr...

    In C Langage Write a grading program for a class with the following grading policies:- a. There are two quizzes, each graded on the basis of 10 points. b. There is one midterm exam and one final exam, each graded on the basis of 100 points. c. The final exam counts for 50 percent of the grade, the midterm counts for 25 percent and the two quizzes together count for a total of 25 percent. Grading system is as follows:-...

  • Write a program to calculate your final grade in this class. Three(8) assignments have yet to...

    Write a program to calculate your final grade in this class. Three(8) assignments have yet to be graded: Quiz 7, Lab 7 and Final Project. Assume ungraded items receive a grade of 100 points. Remember to drop the lowest two quiz scores. Display final numeric score and letter grade. Implementation: Weight distribution is listed in canvas. Use arrays for quizzes, labs, projects and exams. You are allowed to use initialization lists for arrays. Use at least three (3) programmer defined...

  • Task 5 Download the ENG1060studentmarks.txt file from the Moodle. The file contains the following...

    use Matlab to solve this problem, thank you Task 5 Download the ENG1060studentmarks.txt file from the Moodle. The file contains the following information: 1. 2, 3, 4, Column 1: Student ID Column 2-11: Lab marks (/10) worth 2% each (20% total of final grade) Column 12: Assignment mark (/10) worth 10% of the final grade Column 13: Exam mark (/100) worth 70% of the final grade a) Write a function that accepts a student's laboratory, assignment and exam marks as...

  • Must be done in C# please! Thanks! In this assignment you will create a program named...

    Must be done in C# please! Thanks! In this assignment you will create a program named Test Scores that displays the average of all tests; average midterm score; average final score; and displays the midterm or final score of a particular student. Create a class level two dimensional integer array named Grades initialized with the following data: 897 242 301 987 116 450 865 128 992 109 88 75 94 70 90 87 81 79 97 79 78 80 92...

  • The Computer Science Instructor has just completed compiling all the grades for the C++ Programming class....

    The Computer Science Instructor has just completed compiling all the grades for the C++ Programming class. The grades were downloaded into a file titled ‘studentGrades.txt’ (attached). Write a C++ Program that reads this file and calculates the following as described : The final semester numeric and letter grade (using 10 point scale) Calculated as follows: Labs 1-6 (worth 50% of final grade) Lab 7 is extra credit (worth 2 % of final grade OR replaces lowest lab grade – Select...

  • Having some coding issues. I can't seem to figure out why my calculation is coming out...

    Having some coding issues. I can't seem to figure out why my calculation is coming out incorrect for the fourth column. For example, mathematically speaking the first row, columns 1-3: ​19, 68, 10. Using the specific equation: finalGrade = e1*.30 + e2*.30 + f*.40. I should get 30.1 in the 4th column but I get otherwise. See provided screenshot. Please explain what I am doing wrong? /* Program info: Fill dd array 30 and 3 of grades Double course[30][3](rows =...

  • Declare and initialize 4 Constants for the course category weights: The weight of Homework will be...

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

  • The task involves writing a C++ program that determines the prime numbers between 1 and 100....

    The task involves writing a C++ program that determines the prime numbers between 1 and 100. The steps you should follow to identify the prime numbers are the following. 1. The number 1 is not a prime number, so it should be scratched. 2. Starting from the first prime number, which is 2, you scratch all the numbers that are the multiple of 2. You should not scratch out 2 itself. 3. The next number in the sequence after the...

  • python 3 question Project Description Electronic gradebooks are used by instructors to store grades on individual assignments and to calculate students’ overall grades. Perhaps your instructor uses gr...

    python 3 question Project Description Electronic gradebooks are used by instructors to store grades on individual assignments and to calculate students’ overall grades. Perhaps your instructor uses gradebook software to keep track of your grades. Some instructors like to calculate grades based on what is sometimes called a “total points” system. This is the simplest way to calculate grades. A student’s grade is the sum of the points earned on all assignments divided by the sum of the points available...

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