Question

In: Computer Science

Professor Al Gorithum has the following grading policy: Every student receives a whole number grade in...

Professor Al Gorithum has the following grading policy:

  • Every student receives a whole number grade in the inclusive range from 0 to 100.
  • Any grade less than 40 is a failing grade.

Al likes to round each student's grade according to these rules:

  • If the difference between the grade and the next multiple of 5 is less than 3, round grade up to the next multiple of 5.
  • If the value of grade is less than 38, no rounding occurs as the result will still be a failing grade.

For example, grade=84 will be rounded to 85 but grade=29 will not be rounded because the rounding would result in a number that is less than 40.

Given the initial grade value for each of Al's students, write code to automate the rounding process.

Detailed Description

  • Begin by asking the user how many students are in the class. Use a loop to validate this input is between 1 and 30.
  • With appropriate prompting, have the user input each student's grade. Use a loop to validate that each grade is in the range [0..100]. Store those grades to an array.
  • Print out a table with 3 columns:
    • Student ID (just use the array subscripts 0, 1, 2, etc.)
    • Original grade
    • Rounded grade

What to submit:

  • Create a Test Plan for a class with at least 5 students. Show the screen interaction. Include a variety of different test cases, including invalid inputs. Save this as a Word document.
  • Be sure your Source Code uses good style and proper documentation.

Solutions

Expert Solution

Hello dear...

I understood the problem statement. But you haven't speified the programming language you want. That's why I wrote the code in C language, as we all know it the mother of programming languages.

C CODE:

//importing stdio.h for i/o purposes
#include <stdio.h>

//roundgrade() funtion to return the rounded grade according to Prof.AI grading policy
int roundgrade(int grade){
        //if grade less than 40 => fail, no need to round the grade
        if(grade<40)
                return grade;
        //if not, student is pass
        else{
                //finding the next multiple of 5 after grade
                int nextmul5 = ((grade/5)+1)*5;
                //if the differene between next multiple of 5 and grade is less than 3
                if(nextmul5-grade < 3){
                        //return the next multiple of 5
                        return nextmul5;
                }
        }
        return grade;
}
//main method
int main(){
        ///initializing requirend variables
        int i,n,grade;
        //prompting user to enter no of students in the class
        printf("Enter no. students in the class(1-30): ");
        scanf("%d",&n);
        //while the no. of students are less than 1 or greater than 30
        while(n<1 || n>30){
                //again prompt the user to enter no of students in the class until it is valid
                printf("Invaid number\nEnter no. students in the class(1-30): ");
                scanf("%d",&n);
        }
        //creating an array to store actual grades and rounded grades of students
        int grades[n],roundedgrades[n];
        //for-loop to prompt the user to enter grades of all students
        for(i=0; i<n; i++){
                printf("Enter grade of student %d: ",i);
                scanf("%d",&grade);
                //while the grade is not in inclusive range of 0-100, prompt the user to enter grade untl it is valid
                while(grade<0 || grade>100){
                        printf("Invaid grade\nEnter grade of student %d: ",i);
                        scanf("%d",&grade);
                }
                //storing the actual grade in grades array
                grades[i] = grade;
                //sroting the rounded grade in roundedgrades array by calling the function for every grade
                roundedgrades[i] = roundgrade(grade);   
        }
        //printing table of gardes
        printf("\n------------------------------------\nStudent's Grades.\n");
        printf("Id\tGrade\trounded Grade\n");
        //for-loop to iterate through the arrays and print actual and rounded grades of all students
        for(i=0; i<n; i++){
                printf("%d\t%d\t%d\n",i,grades[i],roundedgrades[i]);    
        }
        return 0;
        //end
}

IMAGES:

OUTPUT:

Even if you are not doing it in C language, it is easy for you to translate C code to any other languaue.

Hope you will like it.

If you have any doubts ask me in comment section.

If you like my work, please give me a like and feedback. That helps me a lot. Thank you.

All the best


Related Solutions

Professor Stone complains that student teacher ratings depend on the grade the student receives. In other...
Professor Stone complains that student teacher ratings depend on the grade the student receives. In other words, according to Professor Stone, a teacher who gives good grades gets good ratings, and a teacher who gives bad grades gets bad ratings. To test this claim, the Student Assembly took a random sample of 300 teacher ratings on which the student's grade for the course also was indicated. The results are given in the following table. Test the hypothesis that teacher ratings...
Your math professor receives several student emails each day. The probability model shows the number of...
Your math professor receives several student emails each day. The probability model shows the number of emails your professor receives from students in a given day. Feel free to use StatCrunch or other technology to find your solutions. Enter only the solutions into the spaces provided. # student emails 0 1 2 3 4 5 Probability 0.30 0.20 0.10 0.05 0.05 0.30 How many emails should your professor expect to receive daily? Round your result to the nearest hundredth. What...
Your math professor receives several student emails each day. The probability model shows the number of...
Your math professor receives several student emails each day. The probability model shows the number of emails your professor receives from students in a given day. # student emails 0 1 2 3 4 5 Probability 0.10 0.10 0.20 0.20 0.30 0.10 How many emails should your professor expect to receive daily? Round your result to the nearest hundredth. What is the standard deviation of the number of emails your professor should expect to receive? Round to the nearest hundredth....
Let X be the exam grade of a student taking Calculus 1 with Professor Smith. The...
Let X be the exam grade of a student taking Calculus 1 with Professor Smith. The professor believes that X has a mean of 76 and a standard deviation of 12.5. Suppose there are 100 students in Professor Smith's class. Approximate the probability that X is between 73.8 and 77.8.
Let X be the exam grade of a student taking Calculus 1 with Professor Smith. The...
Let X be the exam grade of a student taking Calculus 1 with Professor Smith. The professor believes that X has a mean of 81 and a standard deviation of 22. Suppose there are 100 students in Professor Smith's class. Approximate the probability that X is higher than 83.6 OR smaller than 79.2?
Indicate the death benefit the beneficiary receives after income taxes on a whole life policy with...
Indicate the death benefit the beneficiary receives after income taxes on a whole life policy with the following values. Policy loan: $1000000, Policy Dividend: $500000, Cash Value: $2000000, Policy Face Value: $5000000, Premiums Paid: $1250000, Marginal Income Tax Bracket of Beneficiary 30%
1. ​ a)​Write a Matlab program to define student grade program and student number with if-else...
1. ​ a)​Write a Matlab program to define student grade program and student number with if-else statement logic​​​​​​​​​ b)​Write a Matlab program for sensor selection of temperature, pressure, flow sensor with if-else statement logic​​​​​​​​​ ​ 2.​Assume there are four letters from an information source with probabilities as A1 0.5 A2 0.3 A3 0.1 A4 0.1 Generate the tag and find the corresponding gaps and binary values for each stage and the sequence of the symbols which are coded are a1a3a2a4a1.​​​...
My introduction to taxation professor changed the grading scale without notifying us. The syllabus has not...
My introduction to taxation professor changed the grading scale without notifying us. The syllabus has not changed at all during or towards the end of the semester. We never knew that she changed the scale until our grades for the course were published. The syllabus states that an 87% to 89% is a B+ and that percentages that are .5% will be rounded up. My final percentage earned in the class was 86.74%, which qualifies for that round up. The...
A professor has noticed that, even though attendance is not a component of the final grade...
A professor has noticed that, even though attendance is not a component of the final grade for the class, students that attend regularly generally get better grades. In fact, 48% of those who come to class on a regular basis receive A's. Only 6% who do not attend regularly get A's. Overall, 60% of students attend regularly. Based on this class profile, suppose we are randomly selecting a single student from this class, and answer the questions below. Hint #1:...
A professor has noticed that, even though attendance is not a component of the final grade...
A professor has noticed that, even though attendance is not a component of the final grade for the class, students that attend regularly generally get better grades. In fact, 36% of those who come to class on a regular basis receive A's. Only 4% who do not attend regularly get A's. Overall, 60% of students attend regularly. Based on this class profile, suppose we are randomly selecting a single student from this class, and answer the questions below. Hint #1:...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT