Question

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.

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

Source Code:

#include <iostream>

using namespace std;
//creating a class
class Main{
   //display grade function
private:static void displayGrade(double score, char grade){
//printing the score;
cout<<"Score is "<<score;
//printing the grade;
cout<<" Grade is "<<grade;

}
//calclating grade method
public:void calculateGrade(bool a[]){
    //intitalizing the score to 5
    double score=5;
    //variable to store grade
    char grade;
for(int i=0;i<20;i++){
    if(a[i]==0){
        //if it is wrong score reduced by 5
        score-=0.5;
           }else{
              // if it is correct score added by 5
              score+=5;
           }
       }
       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);
}
};


  
int main()
{
  
Main obj;
//creating object
bool a[20]={false};
//read values from system

int n;
for(int i=0;i<20;i++){
cout<<"enter"<< i <<"value 0 for false 1 For True ";
//read whether question is correct or not if it zero it is false else it is true
cin>>n;
if(n==0)
a[i]=0;
else
a[i]=1;
}
//cal to calculate grade and print it
obj.calculateGrade(a);

return 0;
}

Code Image

OUTPUT:

// We may get negative values since there is negative marking if the question is wrong

Add a comment
Answer #2

Coding

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MCQTest
{
class Program
{
private static void displayGrade(double score, char grade){
Console.WriteLine("Your Score is ::" + Convert.ToString(score));//output display score
Console.WriteLine("Your Grade is ::" + Convert.ToString(grade));//output display grade
}
static void Main(string[] args)
{
String[] question = new String[20] { "What is Capital Of India", "What is Capital Of Gujarat", "What is Capital Of India", "What is Capital Of Gujarat", "What is Capital Of India", "What is Capital Of Gujarat", "What is Capital Of India", "What is Capital Of Gujarat", "What is Capital Of India", "What is Capital Of Gujarat", "What is Capital Of India", "What is Capital Of Gujarat", "What is Capital Of India", "What is Capital Of Gujarat", "What is Capital Of India", "What is Capital Of Gujarat", "What is Capital Of India", "What is Capital Of Gujarat", "What is Capital Of India", "What is Capital Of Gujarat" };//HERE IS THE QUESTION LIST PLEASE MAKE YOUR OWN QUESTION LIST HERE I REPETEADED TWO QUESTION ALL THAT TIME ONLY
String[] A = new String[20] { "Delhi", "Baroda", "Delhi", "Baroda", "Delhi", "Baroda", "Delhi", "Baroda", "Delhi", "Baroda", "Delhi", "Baroda", "Delhi", "Baroda", "Delhi", "Baroda", "Delhi", "Baroda", "Delhi", "Baroda" };//OPTION A LIST
String[] B = new String[20] { "Kalkata", "Ahmdabad", "Kalkata", "Ahmdabad", "Kalkata", "Ahmdabad", "Kalkata", "Ahmdabad", "Kalkata", "Ahmdabad", "Kalkata", "Ahmdabad", "Kalkata", "Ahmdabad", "Kalkata", "Ahmdabad", "Kalkata", "Ahmdabad", "Kalkata", "Ahmdabad" };//OPTION B LIST
String[] C = new String[20] { "Goa", "Gandhinagar", "Goa", "Gandhinagar", "Goa", "Gandhinagar", "Goa", "Gandhinagar", "Goa", "Gandhinagar", "Goa", "Gandhinagar", "Goa", "Gandhinagar", "Goa", "Gandhinagar", "Goa", "Gandhinagar", "Goa", "Gandhinagar" };//OPTION C LIST ALL
String[] D = new String[20] { "Jaypur", "Bhuj", "Jaypur", "Bhuj", "Jaypur", "Bhuj", "Jaypur", "Bhuj", "Jaypur", "Bhuj", "Jaypur", "Bhuj", "Jaypur", "Bhuj", "Jaypur", "Bhuj", "Jaypur", "Bhuj", "Jaypur", "Bhuj" };//OPTION D LIST
String[] Answer = new String[20] { "A", "B", "A", "B", "A", "B", "A", "B", "A", "B", "A", "B", "A", "B", "A", "B", "A", "B", "A", "B" };//CORRECT ANSWER HERE
double score = 0;
Char grade=new Char();
for (int i = 0; i < question.Length; i++)
{
String YourAnswer;
Console.WriteLine("Question Number ::("+(i+1)+") "+Convert.ToString(question[i]));//OUTPUT DISPLAY OF QUESTION
Console.WriteLine("A)"+A[i]);//OUTPUT DISPLAY OPTION A
Console.WriteLine("B)"+B[i]);//OUTPUT DISPLAY OPTION B
Console.WriteLine("C)"+C[i]);//OUTPUT DISPLAY OPTION C
Console.WriteLine("D)"+D[i]);//OUTPUT DISPLAY OPTION D
Console.Write("Press Your Answer From(A,B,C,D) :");//write your answer
YourAnswer = Console.ReadLine();//readline from user
if (YourAnswer.Equals(Answer[i]))//if the answer is correct then
{
score = score + 5;//increment score here
}
else
{
score = score - 5;//decrement score here
}
}
if (score > 90)
{
grade = 'A'; //define grade
}
else if (score >= 80)
{
grade = 'B';//define grade
}
else if (score >= 70)
{
grade = 'C';//define grade
}
else if (score >= 60)
{
grade = 'D';//define grade
}
else if (score < 60)
{
grade = 'F';//define grade
}
displayGrade(score,grade);//call to display
}
}
}

output:

if you still have any Problem regarding this question please comment and if you like my code please appreciate me by thumbs up thank you.........

Add a comment
Know the answer?
Add Answer to:
Question: How do I write a program in C# that calculates a student's final grade for...
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
  • Write a program called printGPA. The program should contain at least 3 methods: main, gradeAverage, and...

    Write a program called printGPA. The program should contain at least 3 methods: main, gradeAverage, and letterGrade. The user will type a line of input containing the student's name, then a number that represents the number of scores, followed by that many integer scores (user input is in bold below). The data type used for the input should be one of the primitive integer data types. Here are two example dialogues: Enter a student record: Maria 5 72 91 84...

  • Your assignment is to write a grade book for a teacher. The teacher has a text file, which includ...

    Your assignment is to write a grade book for a teacher. The teacher has a text file, which includes student's names, and students test grades. There are four test scores for each student. Here is an example of such a file: Count: 5 Sally 78.0 84.0 79.0 86.0 Rachel 68.0 76.0 87.0 76.0 Melba 87.0 78.0 98.0 88.0 Grace 76.0 67.0 89.0 0.0 Lisa 68.0 76.0 65.0 87.0 The first line of the file will indicate the number of students...

  • Write a grading program for the following grading policies:- a. There are two quizzes, each graded...

    Write a grading program for 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:- >90 A >=80 and <90 B...

  • [Using Python] Use the grade scale in the syllabus for this class, write a program that...

    [Using Python] Use the grade scale in the syllabus for this class, write a program that inputs a score, and prints the grade for that score. For example, if I input 90.0, your program should print A. Grading Scale is: 100% - 90% A 89% - 80% B 79% - 70% C 69% - 60% D 59% - 0% E

  • C++ Write a program to calculate final grade in this class, for the scores given below...

    C++ Write a program to calculate final grade in this class, for the scores given below . Remember to exclude one lowest quiz score out of the 4 while initializing the array. Display final numeric score and letter grade. Use standard include <iostream> Implementation: Use arrays for quizzes, labs, projects and exams. Follow Sample Output for formatting. May use initialization lists for arrays. Weight distribution is as follows: Labs: 15% Projects: 20% Quizzes: 20% Exams: 25% Final Project: 20% Display...

  • using C# Write a program which calculates student grades for multiple assignments as well as the...

    using C# Write a program which calculates student grades for multiple assignments as well as the per-assignment average. The user should first input the total number of assignments. Then, the user should enter the name of a student as well as a grade for each assignment. After entering the student the user should be asked to enter "Y" if there are more students to enter or "N" if there is not ("N" by default). The user should be able to...

  • i,, Question Help * 2.3.41 Percent of final grade 15 Score Homework83 Quiz Quiz Project Final...

    i,, Question Help * 2.3.41 Percent of final grade 15 Score Homework83 Quiz Quiz Project Final Exam 85 The scores and their percent of the final grade for a statistics student are given. What is the student's weighted mean score? The student's weighted mean score is (Simplify your answer. Round to two decimal places as needed.)

  • Write a C++ program that asks the user for an exam score. The program displays on...

    Write a C++ program that asks the user for an exam score. The program displays on the screen the appropriate later grade as per the schema below: a. A: [90-100] b. B: [80:89] c. C: [70:79] d. D: [60:69] e. F: otherwise

  • I need #5 done i cant seem to understand it. it must be written in c++...

    I need #5 done i cant seem to understand it. it must be written in c++ 4. Numeric Processing Write a program that opens the file "random.txt", reads all the numbers from the file, and calculates and displays the following: a. The number of numbers in the file. b. The sum of all the numbers in the file (a running total) c. The average of all the numbers in the file numFile.cpp Notes: Display the average of the numbers showing...

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

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