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

Write a program that calculates the student's final grade for a test with 20 multiple questions...
Write a program that calculates the student's final grade for a test with 20 multiple questions using C# .net Framework. se an array of integers to store the test scores (0-incorrect answer, 1-correct answer). Initialize it as follows: int [] scores = {1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1}; 3. If the student answered the question right, add 5 points to the running total. If the student...
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 named, myGrade.cpp, that calculates a letter grade for a student of this...
Write a C++ program named, myGrade.cpp, that calculates a letter grade for a student of this course (CSC100 online) based on three user inputs. This program should begin by printing the title of the application (program) and a brief description of what it does. (Note: this is NOT the same as the program prolog: a prolog is much more detailed, has required elements, and is intended for other programmers reading the cpp file. The title and description displayed by the...
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...
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 termtest and final grade. The program must first ask the user how many students there are. Then, for each student, the program will ask the user for the termtest grade (grade #1) and final grade (grade #2). The program should be able to handle up to 100 students, each with 2 grades (termtest and final). Use a two dimensional float array to...
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...
C++ Description: You will write a program that reads students names followed by their final grade....
C++ Description: You will write a program that reads students names followed by their final grade. It will output the names and their grade, followed by the corresponding letter grade. It will also print the name of the students(s) with the highest grade Student data will be stored in a struct called studentType which has 4 members: fName lName score letterGrade Assume there are 20 students Your main() function will only have variable definitions and function calls You MUST have...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT