Question

In: Computer Science

Question: How do I write a program in C# that calculates a student's final grade for...

Question: How do I write a program in C# that calculates a student's final grade for a test with 20 multiple questions using arrays and helper methods?

Instructions: (0-incorrect answer, 1-correct answer) If the student answered the question right, add .5 points to the running total. If the student didn’t answer correctly subtract .5 points from the running total. The running total is initialized with 5 points (so the student receives 5 points extra credit). To define the final grade use the grading scale below

Score Grade

90+ A

80-89 B

70-79 C

60-69 D

<60 F

Write a helper method displayScoreGrade()that displays the score and calculated grade.

private static void displayGrade(double score, char grade)

{ //printing the score; //printing the grade; ... } Call the method from the main method.

Solutions

Expert Solution

using System;

class test

{

    private static void displayGrade(double score, char grade)

    {

        Console.WriteLine("Total Score: " + score);

        Console.WriteLine("Grade: " + grade);

    }

    public static void Main(String[] args)

    {

        double score = 5;

        double correct = 5;

        //read 20 scores

        for (int i = 0; i < 20; i++)

        {

            Console.Write("Enter Score of Q-" + (i + 1) + ": ");

            int current = int.Parse(Console.ReadLine());

            if (current == 1)

                score += correct;

        }

        char grade;

        if (score >= 90)

            grade = 'A';

        else if (score >= 80)

            grade = 'B';

        else if (score >= 70)

            grade = 'C';

        else if (score >= 60)

            grade = 'D';

        else

            grade = 'F';

        displayGrade(score,grade);

    }

}

Screenshot of code:

Output:

Enter Score of Q-1: 1 Enter Score of Q-2: 0 Enter Score of Q-3: 1 Enter Score of Q-5: 1 Enter Score of Q-6: 1 Enter Score of Q-7: 1 Enter Score of Q-8: 1 Enter Score of Q-9: 0 Enter Score of Q-10: 1 Enter Score of Q-11: 1 Enter Score of Q-12: 1 Enter Score of Q-13: 1 Enter Score of Q-14: 1 Enter Score of Q-15: 1 Enter Score of Q-16: 0 Enter Score of Q-17: 1 Enter Score of Q-18: 1 Enter Score of Q-19: 1 Enter Score of 0-20: 1 Total Score: 90 Grade: A

TJ L. LIALI . 1.CAL Enter Score of Q-1: 0 Enter Score of Q-2: 0 Enter Score of Q-3: 0 Enter Score of Q-4: 0 Enter Score of 2-5: 1 Enter Score of 0-6: 0 Enter Score of Q-7: 1 Enter Score of Q-8: 1 Enter Score of 0-9: 1 Enter Score of Q-10: 1 Enter Score of Q-11: 0 Enter Score of Q-12: 1 Enter Score of Q-13: 1 Enter Score of Q-14: 1 Enter Score of Q-15: 1 Enter Score of Q-16: 0 Enter Score of Q-17: 0 Enter Score of Q-18: 1 Enter Score of Q-19: 1 Enter Score of 0-20: 1 Total Score: 65 Grade: D


Related Solutions

C# CODE C# 1) Write a program that calculates a student's GPA. Remember, an A is...
C# CODE C# 1) Write a program that calculates a student's GPA. Remember, an A is worth 4 points, a B is worth 3 points, a C is worth 2 points, a D is worth 1 point, and an F is worth 0 points. For the purposes of this assignment, assume that all classes carry the same number of credit hours. 2) Use a sentinel-controlled loop to gather a variable number of letter grades. This should terminate the loop if...
Write a C program that calculates a student grade in the C Programming Class. Ask the...
Write a C program that calculates a student grade in the C Programming Class. Ask the user to enter the grades for each one of the assignments completed in class: Quiz #1 - 25 points Quiz #2 - 50 points Quiz #3 - 30 points Project #1 - 100 points Project #2 - 100 points Final Test - 100 points The total of the quizzes count for a 30% of the total grade, the total of the projects counts for...
Write a C program that calculates the average grade for a specified number of students from...
Write a C program that calculates the average grade for a specified number of students from each student's test1 and test2 grades. The program must first ask the user how many students there are. Then, for each student, the program will ask the user for the test1 grade (grade #1) and test2 grade (grade #2). The program should be able to handle up to 100 students, each with 2 grades (test1 and test2). Use a two-dimensional float array to store...
Create the pseudocode solution to a program that calculates the final score and letter grade for...
Create the pseudocode solution to a program that calculates the final score and letter grade for one student. Please use the following grading system: 9 Homework Assignments – 100 points each 10 points 11 Quizzes – 100 points each 5 points 5 Projects – 100 points each 10 points 6 Discussion posts – 100 points each 10 points 4 Exams – 100 points each 65 points A = 90 – 100% B = 80 – 89% C = 70 –...
Create a small program that calculates the final grade in this course, given the different assignments...
Create a small program that calculates the final grade in this course, given the different assignments and exams you will be required to take. The program should ask for all the grades through the semester, and as a final output it should compute the weighted average as well as give the final letter grade. You should use the syllabus for this course to calculate the final grade. • Five assignments worth 30 points each. • Three projects worth 100 points...
Your task is to write a program in C or C++ that calculates the total amount...
Your task is to write a program in C or C++ that calculates the total amount of money a person has made over the last year. Your program will prompt the user for dollar amounts showing how much the user has made per job. Some users will have had more than one job, make sure your program allows for this. The program will print out the total made (all jobs) and will print out the federal and state taxes based...
Write a C++ program that calculates mileage reimbursement for a salesperson at a rate of $...
Write a C++ program that calculates mileage reimbursement for a salesperson at a rate of $ 0.35 per mile. Your program should interact with the user in this manner: MILEAGE REIMBURSEMENT CALCULATOR Enter beginning odometer reading: 13505.2 Enter ending odometer reading     : 13810.6 You traveled 305.40 miles. At $ 0.35 per mile, your reimbursement is $ 106.89. The values in red color are inputs for the program. The values in blue color are results of expressions.
How do I create this program? Using C++ language! Write a program that reads data from...
How do I create this program? Using C++ language! Write a program that reads data from a text file. Include in this program functions that calculate the mean and the standard deviation. Make sure that the only global varibles are the mean, standard deviation, and the number of data entered. All other varibles must be local to the function. At the top of the program make sure you use functional prototypes instead of writing each function before the main function....ALL...
Write a program in C to grade an n-question multiple-choice exam (for n between 5 and...
Write a program in C to grade an n-question multiple-choice exam (for n between 5 and 20) and provide feedback about the most frequently missed questions. Your program will use a function scan_exam_data to scan and store the exam data in an appropriate data structurer. Use file redirection to input data – do not use fopen() in your code. The first line of input contains the number of students. Second line is number of questions on the exam followed by...
Hotel Occupancy C++ Only Program Description Write a program that calculates the occupancy rate for a...
Hotel Occupancy C++ Only Program Description Write a program that calculates the occupancy rate for a hotel. The program should read its data from a file named "hotel.dat". The first line of this file will be a single integer specifying the number of floors in the hotel. Each of the remaining (N) lines will have two integers; the number of rooms on that floor and the number of occupied rooms on that floor. Your program should display the following: How...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT