Question

In: Computer Science

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 didn’t answer correctly subtract .5 points from the running total.

4. The running total is initialized with 5 points (so the student receives 5 points extra credit).

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

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

Code -


using System;
class HelloWorld {
//function to display Grade
private static void displayGrade(double score, char grade){
//calculate grade according to score
if(score>=90 && score <=100){
grade = 'A';
}
else if(score>=80 && score <=89){
grade = 'B';
}
else if(score>=70 && score <=79){
grade = 'C';
}
else if(score>=60 && score <=69){
grade = 'D';
}
else {
grade = 'F';
}
//print the grade in Console
Console.WriteLine("Total marks is "+score+" grade is "+grade );
}
static void Main() {
//SCORE ARRAY
int [] scores = {1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1};
int i;
//define sum by 5
double sum=5;
char grade='A';
//read the score from array and add marks to sum for correct answer
for(i=0;i<scores.Length;i++){
//correct answer check
if(scores[i] == 1){
sum+=5;
}
//incorrect answer check
else{
sum-=0.5;
}
}
//call function to dislay grade
displayGrade(sum,grade);

}
}

Screenshots -


Related Solutions

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...
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# 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 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 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...
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...
Write a program that calculates the average of a group of test scores, where the lowest...
Write a program that calculates the average of a group of test scores, where the lowest score in the group is dropped. It should use the following functions: void getScore() should ask the user for a test score, store it in a reference parameter variable, and validate it. This function should be called by main once for each of the five scores to be entered. void calcAverage() should calculate and display the average of the four highest scores. This function...
Write a C++ program to read in various types of test questions (multiple choice and True/False)...
Write a C++ program to read in various types of test questions (multiple choice and True/False) from a test bank (text file), and load the questions into an array of questions. You will need to implement the following class hierarchy (given in UML): Once the test bank has been loaded, simply iterate over the array of questions and have each question printed out to the screen. The test bank (text file) will have the following format: Line 1 will be...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT