Question

In: Computer Science

Using C# create a new grade book program for a teacher. We have a class with...

Using C# create a new grade book program for a teacher.

We have a class with 10 students who have each taken 5 tests. Create an array to hold:

  1. Each student’s name
  2. Each test grade
  3. The average for each student's tests

Use a random number generator to generate the test scores for each student. The student names may be hard-coded into the array.

Create and call a method that calculates and stores each student’s average in the array.

Create and call a method that displays the grades and average for each student.

Solutions

Expert Solution

using System;


namespace Main {
    
    // string name;
    // int marks[5];
    // string color="red"    ;
    
    class Grades{
        public string name;
        public int[] marks=new int[5];
        public double average;
        
        
        public Grades(string name, int [] arr){
            this.name=name;
            this.marks=arr;
        }
        
        public void calculate(){
            int sum=0;
            for(int i=0;i<5;i++)
            sum+=marks[i];
            
            average=(sum)/5;
        }
        
        public void showdata(){
            Console.WriteLine("Name: "+name);
            for(int i=0;i<5;i++)
            Console.WriteLine("Marks in subject {0}={1}",i+1,marks[i] );
            
            Console.WriteLine("Average is :"+average);
            
        }
        
    }
        
    
    class helperclass{
    
        public static void Main(string[] args) {
                
                int n=10; // students 
                
                for(int i=1;i<=10;i++){
                string name;
                int[] marks=new int[5];
                
                name=Console.ReadLine(); // input name 
                for(int j=0;j<5;j++)
                {
                    Random r=new Random();
                    marks[j]=r.Next(1,100); // genrate marks
                }
                
                Grades g= new Grades(name,marks);
                g.calculate();
                g.showdata();
                Console.WriteLine();
                
                }
    
                
        }
        
    }
}

Related Solutions

C++ Programming Create a C++ program program that exhibits polymorphism. This file will have three class...
C++ Programming Create a C++ program program that exhibits polymorphism. This file will have three class definitions, one base class and three derived classes. The derived classes will have an inheritance relationship (the “is a” relationship) with the base class. You will use base and derived classes. The base class will have at least one constructor, functions as necessary, and at least one data field. At least one function will be made virtual. Class members will be declared public and...
C++ program using Eclipse IDE The C++ program should have concurrency. The C++ program should create...
C++ program using Eclipse IDE The C++ program should have concurrency. The C++ program should create 2 threads that will act as counters. One thread should count down from 5 to 0. Once that thread reaches 0, then a second thread should be used to count up to 20.
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...
Using C# Create the “TestQuestion” class. It will have two class variables: 1) a question and...
Using C# Create the “TestQuestion” class. It will have two class variables: 1) a question and 2) the answer to that question. Please create an accessor and mutator method for both of those variables, without which we would not be able to see or change the question or the answer. There should be a constructor method. We will also have a “ToString” or “__str__” method, which will print the question followed by its answer. The constructor method has two parameters...
(In C++) Bank Account Program Create an Account Class Create a Menu Class Create a main()...
(In C++) Bank Account Program Create an Account Class Create a Menu Class Create a main() function to coordinate the execution of the program. We will need methods: Method for Depositing values into the account. What type of method will it be? Method for Withdrawing values from the account. What type of method will it be? Method to output the balance of the account. What type of method will it be? Method that will output all deposits made to the...
Write a C program that prints the Grade of each student in a class based on...
Write a C program that prints the Grade of each student in a class based on their mark. The program must also print the average mark of the class. The program must prompt (ask) the user for the mark of a student (out of 100). The program must then print the mark entered and the grade received based on the table below. Grade Range A 85 to 100 inclusive B 75 to 85 inclusive C 60 to 70 inclusive D...
Create “New Class…” named Book to store the details of a book Declare 3 fields for...
Create “New Class…” named Book to store the details of a book Declare 3 fields for the details of the book: field named author of type String field named title of type String field named callNumber of type String Add overloaded constructors with the following headers and make sure each constructor has only 1 statement in the body that makes an internal method call to setBookDetails: public Book(String author, String title, String callNumber) public Book(String author, String title) HINT: Initialize...
create a project and in it a class with a main. We will be using the...
create a project and in it a class with a main. We will be using the Scanner class to read from the user. At the top of your main class, after the package statement, paste import java.util.Scanner; Part A ☑ In your main method, paste this code. Scanner scan = new Scanner(System.in); System.out.println("What is x?"); int x = scan.nextInt(); System.out.println("What is y?"); int y = scan.nextInt(); System.out.println("What is z?"); int z = scan.nextInt(); System.out.println("What is w?"); int w = scan.nextInt();...
********************C# C# C#******************** Part A: Create a project with a Program class and write the following...
********************C# C# C#******************** Part A: Create a project with a Program class and write the following two methods(headers provided) as described below: 1. A Method, public static int InputValue(int min, int max), to input an integer number that is between (inclusive) the range of a lower bound and an upper bound. The method should accept the lower bound and the upper bound as two parameters and allow users to re-enter the number if the number is not in the range...
C++ * Program 2:      Create a date class and Person Class.   Compose the date class...
C++ * Program 2:      Create a date class and Person Class.   Compose the date class in the person class.    First, Create a date class.    Which has integer month, day and year    Each with getters and setters. Be sure that you validate the getter function inputs:     2 digit months - validate 1-12 for month     2 digit day - 1-3? max for day - be sure the min-max number of days is validate for specific month...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT