Question

Using C#: • Create a "Grades" class with the private variables: double grade1, double grade2, double...

Using C#:

• Create a "Grades" class with the private variables: double grade1, double grade2, double grade3, double grade4, double grade5.

• In the Main method, ask the user to enter the five grades.

• In the ToString() method of the Grades class, print out the mean average (Example: Average: 86).

• Also, in the ToString() method of the Grades class, print out the 5 grades that were entered from highest to lowest. For example, if the user entered: 100, 80, 90, 75, 95, the ToString() method would print out, “Grade 1: 100, Grade 4: 95, Grade 3: 90, Grade 2: 80, Grade 4: 75.”

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

Program:

using System;
namespace Marks
{
class Grades
{
private double grade1;
private double grade2;
private double grade3;
private double grade4;
private double grade5;
  
public void getGrades(double g1, double g2, double g3, double g4, double g5)
{
grade1=g1;
grade2=g2;
grade3=g3;
grade4=g4;
grade5=g5;
}
  
public void ToString()
{
double average=(grade1+grade2+grade3+grade4+grade5)/5;
Console.WriteLine("Average: "+average);
double[] a={grade1, grade2, grade3, grade4, grade5};
double[] b={grade1, grade2, grade3, grade4, grade5};
Array.Sort(b);
for(int i=4;i>=0;i--)
{
for(int j=0;j<5;j++)
{
if(a[i]==b[j])
{
Console.WriteLine("Grade "+(j+1)+": "+a[i]);
}
}
}
}
}
class GradesChecker
{
static void Main()
{
Grades g=new Grades();
Console.WriteLine("Enter the five grades");
double grade1=Convert.ToDouble(Console.ReadLine());
double grade2=Convert.ToDouble(Console.ReadLine());
double grade3=Convert.ToDouble(Console.ReadLine());
double grade4=Convert.ToDouble(Console.ReadLine());
double grade5=Convert.ToDouble(Console.ReadLine());
g.getGrades(grade1, grade2, grade3, grade4, grade5);
g.ToString();
}
}
}

Screenshot of the Code:

for(int i=4;i>=0; i--) { for(int j =0; j<5; j++) { if(a[i]==b[j]) { Console.WriteLine(Grade +(j+1)+: +a[i]); } } } class

Output:

Enter the five grades 95 96 98 97 99 Average: 97 Grade 5: 99 Grade 3: 97 Grade 4: 98 Grade 2: 96 Grade 1: 95

Add a comment
Know the answer?
Add Answer to:
Using C#: • Create a "Grades" class with the private variables: double grade1, double grade2, double...
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
  • I ONLY need question 2 part C AND D answered...it is in bold. Please do not...

    I ONLY need question 2 part C AND D answered...it is in bold. Please do not use hash sets or tables. In java, please implement the classes below. Each one needs to be created. Each class must be in separate file. The expected output is also in bold. I have also attached the driver for part 4 to help. 1. The Student class should be in the assignment package. a. There should be class variable for first and last names....

  • Hello, Can you please error check my javascript? It should do the following: Write a program...

    Hello, Can you please error check my javascript? It should do the following: Write a program that uses a class for storing student data. Build the class using the given information. The data should include the student’s ID number; grades on exams 1, 2, and 3; and average grade. Use appropriate assessor and mutator methods for the grades (new grades should be passed as parameters). Use a mutator method for changing the student ID. Use another method to calculate the...

  • create an application that calculates the grades of students Wilbur Wright College CIS 142 C++ Programming...

    create an application that calculates the grades of students Wilbur Wright College CIS 142 C++ Programming Language Prof. Gustavo Alatta Lab #4 Points: 100 1.1. Create an application that calculates the grades of a group of students. The program must follow these specifications: - You need to declare 2 arrays: 1 single String array to contain the name of the students and the second a double two-dimensional to hold the grades of the students. - The program must allow the...

  • The Computer Science Instructor has just completed compiling all the grades for the C++ Programming class....

    The Computer Science Instructor has just completed compiling all the grades for the C++ Programming class. The grades were downloaded into a file titled ‘studentGrades.txt’ (attached). Write a C++ Program that reads this file and calculates the following as described : The final semester numeric and letter grade (using 10 point scale) Calculated as follows: Labs 1-6 (worth 50% of final grade) Lab 7 is extra credit (worth 2 % of final grade OR replaces lowest lab grade – Select...

  • Java please 9:55 Note @13 simple lists of numbers. If the user selects option 2, your...

    Java please 9:55 Note @13 simple lists of numbers. If the user selects option 2, your program should prompt for a list of integer grades (0 100, inclusive). When the list is entered print out the following statistics: total grades, the breakdown of grades by letter both count and percentage), the highest and lowest grades in the list, and the class average Example #1 Please enter a list of grades (0-100): 55 65 75 85 95-1 Total number of grades...

  • Create a class called Student. This class will hold the first name, last name, and test...

    Create a class called Student. This class will hold the first name, last name, and test grades for a student. Use separate files to create the class (.h and .cpp) Private Variables Two strings for the first and last name A float pointer to hold the starting address for an array of grades An integer for the number of grades Constructor This is to be a default constructor It takes as input the first and last name, and the number...

  • C++: Create a grade book program that includes a class of up to 20 students each...

    C++: Create a grade book program that includes a class of up to 20 students each with 5 test grades (4 tests plus a Final). The sample gradebook input file (CSCI1306.txt) is attached. The students’ grades should be kept in an array. Once all students and their test scores are read in, calculate each student’s average (4 tests plus Final counts double) and letter grade for the class. The output of this program is a tabular grade report that is...

  • First, create two inputs that can be stored in variables consisting of a student's name. When...

    First, create two inputs that can be stored in variables consisting of a student's name. When the program begins ask "Who is the first student?" followed by "Who is the second student?" You only have to have two students for this program. Ask the user for the scores for the last three test grades for each of the students .   After the user has entered both names, and three scores for each, the program should display the following as output:...

  • help 6. (15 points) Define class GradeStat to describe the grades of all people in a...

    help 6. (15 points) Define class GradeStat to describe the grades of all people in a group. (1) Declare data member grades as an array of integers (we can declare it as a double type, but use int type can be simpler). (2) Write a constructor taking an array of int as input parameter. Use it to initialize data member. Note that each element in the array should be a non- negative int not larger than 100, that is, an...

  • PLEASE DO THIS IN C#.Design and implement a program (name it ProcessGrades) that reads from the...

    PLEASE DO THIS IN C#.Design and implement a program (name it ProcessGrades) that reads from the user four integer values between 0 and 100, representing grades. The program then, on separate lines, prints out the entered grades followed by the highest grade, lowest grade, and averages of all four grades. Format the outputs following the sample runs below. Sample run 1: You entered: 95, 80, 100, 70 Highest grade: 100 Lowest grade: 70 Average grade: 86.25

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