Question

In: Computer Science

This is in C# on visual Basic Write a base class that has two property members:...

This is in C# on visual Basic

  1. Write a base class that has two property members: name and contact and one method member: CalculateFinalGrade(). must be an Abstract class method must be by its child class. (1 point)

For example,

Student {

                Property: StudentName

                Property: Contact

                Method: CalculateFinalGrade()

}

  1. Write two child classes and , both of which inherit and implement any abstract member. needs a property for Quiz score and implements CalculateFinalGrade() to calculate final the grade in LETTER (based on Quiz score only). needs two properties, one for quiz score and the other for term paper score, and implements CalculateFinalGrade() to calculate the final grade in LETTER (based on both Quiz and Team Paper scores). The maximum quiz score for both undergraduate and graduate is 250. The maximum term paper score for graduate only is 50. For undergraduate, the final grade is calculated with the formula: (quiz score/250). For graduate, the formula is ((quiz + term paper)/300). In the CalculateFinalGrade(), the calculated final grade in percentage must be converted to the LETTER grade as (A: >=90%; B: >=80% and <90%; C: >=70% and <80%; D: >=60% and <70%; F: <60%). That is, CalculateFinalGrade() will return a LETTER grade. (2 points)

For example, (note: the following are pseudo codes, not C#)

UndergraduateStudent : Student {

Property: QuizScore

Method: CalculateFinalGrade {

      theQuiz = QuizScore/250

                     if theQuiz >= 0.90 then

                        finalGrade = "A"

                 else if theQuiz >= 0.80 then

                        finalGrade = "B"

                 ...

                else if theQuiz <= 0.60 then

                        finalGrade = "F"

finalGrade

}

Note:

  1. You can have both and to inherit and overrides the CalculateFinalGrade() in each of them. OR inherits and inherits . That is, the CalculateFinalGrade() in is overridden by the same method in its child class , which is further overridden in its child class .
  2. You can use either switch case… or if .. else if.

3. Use the classes in the above to implement the GradeCalculation program as follows. (2 points)

In this program, you don’t need to implement data validation (even though I did it in the demo program). Make sure to hide the Term Paper textbox when the undergraduate is selected.

Solutions

Expert Solution

Source Code:

using System;

class Student {

protected string name;

protected string no;

protected string s;

public void getdetails(){

Console.WriteLine("Enter Name:");

name = Console.ReadLine();

Console.WriteLine("Enter PhoneNumber:");

no = Console.ReadLine();

}

public void printdetails(){

Console.WriteLine("Name:"+name+"\n");

Console.WriteLine("PhoneNumber:"+no+"\n");

}

public string CalculateFinalGrade(double a){


if(a>=90){s="A";}

else if(a<90 && a>=80){s= "B";}

else if(a<80 && a>=70){s="C";}
  
else if(a<70 && a>=60){s="D";}
  
else if(a<60){s="F";}
  
Console.WriteLine(s);
  
return s;
  
}
  
static void Main() {
int ch;
  
Graduate g1 = new Graduate();
  
underGraduate u1 = new underGraduate();
  
Console.WriteLine("1.Under Graduate\n2.Graduate");
  
Console.WriteLine("Enter Your Choice:");
  
ch = Convert.ToInt32(Console.ReadLine());
  
if(ch == 1)
{
  
u1.getData();
  
u1.printData();
}
  
if(ch == 2)
  
{
  
g1.getData();
  
g1.printData();
  
  
}
}
}
class Graduate : Student // Derived Class
{
int quiz_score,term_score;
  
string s;
  
public void getData(){
  
getdetails();
  
Console.WriteLine("Enter quiz_score(out of 250):");
  
s = Console.ReadLine();
  
quiz_score = Convert.ToInt32(s);
  
  
Console.WriteLine("Enter term_score(out of 50):");
  
s = Console.ReadLine();
  
term_score = Convert.ToInt32(s);
  
double total_percentage = (quiz_score + term_score)/3;
  
s = CalculateFinalGrade(total_percentage);
  
  
}
  
public void printData(){
  
printdetails();
  
Console.WriteLine("Quiz Score:"+quiz_score);
  
Console.WriteLine("Term Score:"+term_score);
  
Console.WriteLine("Total Score:300");
  
Console.WriteLine("Grades:"+s);
}
  
}

class underGraduate : Student
{

int quiz_score;

public void getData(){

getdetails();

Console.WriteLine("Enter quiz_score(out of 250):");

s = Console.ReadLine();

quiz_score = Convert.ToInt32(s);

  
double total_percentage = (quiz_score)/2.5;

s = CalculateFinalGrade(total_percentage);

  
}
public void printData(){

printdetails();

Console.WriteLine("Quiz Score:"+quiz_score);

Console.WriteLine("Total Score:250");

Console.WriteLine("Grade:"+s);
}
  
}

OUTPUT:

Thankyou

Thumbs Up if you satisfy with answer


Related Solutions

In C++ Define a base class called Person. The class should have two data members to...
In C++ Define a base class called Person. The class should have two data members to hold the first name and last name of a person, both of type string. The Person class will have a default constructor to initialize both data members to empty strings, a constructor to accept two string parameters and use them to initialize the first and last name, and a copy constructor. Also include appropriate accessor and mutator member functions. Overload the operators == and...
C++ Define a base class called Person. The class should have two data members to hold...
C++ Define a base class called Person. The class should have two data members to hold the first name and last name of a person, both of type string. The Person class will have a default constructor to initialize both data members to empty strings, a constructor to accept two string parameters and use them to initialize the first and last name, and a copy constructor. Also include appropriate accessor and mutator member functions. Overload the operators == and !=...
Write a C++ program that creates a base class called Vehicle that includes two pieces of...
Write a C++ program that creates a base class called Vehicle that includes two pieces of information as data members, namely: wheels (type int) weight (type float) Program requirements (Vehicle class): Provide set and a get member functions for each data member. Your class should have a constructor with two parameters (one for each data member) and it must use the set member functions to initialize the two data members. Provide a pure virtual member function by the name displayData()...
In C++ write a program with a base class thet has a pure virtual function SALARY,...
In C++ write a program with a base class thet has a pure virtual function SALARY, and two derived classes. In the first derived class salary is increased by 20%, in the second derived class salary is increased by 30%
Write a class called Person that has two private data members - the person's name and...
Write a class called Person that has two private data members - the person's name and age. It should have an init method that takes two values and uses them to initialize the data members. It should have a get_age method. Write a separate function (not part of the Person class) called std_dev that takes as a parameter a list of Person objects and returns the standard deviation of all their ages (the population standard deviation that uses a denominator...
Language: c++ works in visual basic Write a program that uses an array of nested structs...
Language: c++ works in visual basic Write a program that uses an array of nested structs to store the addresses for your store’s customers.  Each customer has a name and two addresses: home address and business address.  Each address has a street, city, state, and zip code. Requirements: 1. Data structure a. Define an Address struct with street, city, state and zip fields b. Define a Customer struct with lastNm and firstNm fields, plus homeAddr and busAddr fields...
C# 1.Visual Studio .NET’s ___________ feature displays all the members in a class a.real-time error checking...
C# 1.Visual Studio .NET’s ___________ feature displays all the members in a class a.real-time error checking b.Quick Info c.outlined code d.Intellisense 2.An algorithm specifies the actions to be executed. True False 3.A(n) _________ occurs when an executed statement does not directly follow the previously executed statement in the written application. a.unordered execution b.transfer of control c.action state d.jump 4.The declarations and statements that compose the method definition are called the __________.    a.method body b.method header c.parameter list d.method name...
Language: c++ using visual basic Write a program to open a text file that you created,...
Language: c++ using visual basic Write a program to open a text file that you created, read the file into arrays, sort the data by price (low to high), by box number (low to high), search for a price of a specific box number and create a reorder report. The reorder report should alert purchasing to order boxes whose inventory falls below 100. Sort the reorder report from high to low. Inventory data to input. Box number Number boxes in...
Language: c++ using visual basic Write a program to open a text file that you created,...
Language: c++ using visual basic Write a program to open a text file that you created, read the file into arrays, sort the data by price (low to high), by box number (low to high), search for a price of a specific box number and create a reorder report. The reorder report should alert purchasing to order boxes whose inventory falls below 100. Sort the reorder report from high to low. Inventory data to input. Box number Number boxes in...
PLEASE WRITE THIS IN C++ Write a ComplexNumber class that has two member variables realNum and...
PLEASE WRITE THIS IN C++ Write a ComplexNumber class that has two member variables realNum and complexNum of type double. Your class shall have following member functions Complex(); Complex(double, double); Complex add(Complex num1, Complex num2); Complex subtract(Complex num1, Complex num2); string printComplexNumber(); Write a driver program to test your code. Please make sure your code is separated into Complex.h Containing definition of the class Complex.cpp Containing the implementation ComplexTestProgram.cpp Containing main program Use the following directive in class definition to...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT