1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Novosadov [1.4K]
3 years ago
11

We have to calculate the percentage of marks obtained in three subjects (each out of 100) by student A and in four subjects (eac

h out of 100) by student B. Create an abstract class 'Marks' with an abstract method 'getPercentage'. It is inherited by two other classes 'A' and 'B' each having a method with the same name which returns the percentage of the students. The constructor of student A takes the marks in three subjects as its parameters and the marks in four subjects as its parameters for student B. Create an object for eac of the two classes and print the percentage of marks for both the students.
Computers and Technology
1 answer:
MAXImum [283]3 years ago
6 0

Answer:

abstract class Mark  //Creating an Abstract class{

abstract double getPercentage();}

class A extends Mark{

double result;

A( int val1, int val2, int val3){

 result=(val1+val2+val3)/3;}

double getPercentage(){

 return result;}}

class B extends Mark{

double result;

B(int val1, int val2, int val3, int val4){

 result=(val1+val2+val3+val4)/4;}

double getPercentage(){

 return result;}}

class Main{

public static void main(String args[]){

 //class A Object

 Mark obj_1=new A(10,20,30);

 System.out.println(obj_1.getPercentage());

 //class B Object

 Mark obj_2=new B(10,20,38,46);

 System.out.println(obj_2.getPercentage());}}

You might be interested in
Given a PrintWriter reference variable named output that references a PrintWriter object, write a statement that writes the stri
Nadya [2.5K]

Answer:

A PrintWriter reference variable named output that references a PrintWriter object is as follows:

//PrintWriter output = new PrintWriter(outfile);

PrintWriter output = new PrintWriter("output.txt");

The statement that writes the string "Hello World" to the file output is as follows:

//output.print(message)

output.print("Hello World");

Explanation:

4 0
3 years ago
Which compound is obtained by the oxidation of primary alcohol with nascent oxygen​
Nookie1986 [14]

answer:

what

Explanation:

8 0
3 years ago
What steps can be used to password-protect a worksheet?
muminat

Answer:

Review

Changes

Protect sheet

Explanation:

I did it

8 0
3 years ago
A ________ is a virus that is triggered on a certain date.
marysya [2.9K]
A time bomb virus is a virus that is triggered on a certain date. It is a malicious program that is designed to release virus unto a system. Once the time has arrived, it will automatically start working what it is programmed to do since any virus could do anything depending on what it is designed to do.
8 0
3 years ago
What happens when you press Ctrl Alt Delete twice?
Iteru [2.4K]
The same thing as if you do it once
6 0
3 years ago
Other questions:
  • Which of the following is NOT an ethical way of getting to the top of a web search?
    5·1 answer
  • You are using a crimper to attach an RJ-45 connector to a Cat 6 UTP cable. You need to use the T568A standard to connect the ind
    6·1 answer
  • Give two separate print statements: one will print your name, the other will print your major. Ensure that both will print on th
    15·1 answer
  • You have to sort 1 GB of data with only 100 MB of available main memory. Which sorting technique will be most appropriate?
    5·1 answer
  • Search engines use indexes created by web _________ to provide fast searches.
    7·1 answer
  • Should the use of hacktivists by a country against enemy organizations be considered an act of war? Why or why not? How about th
    8·1 answer
  • Explain one way in which programmers may get hired.
    9·1 answer
  • Match each proofreading mark to the expected result.
    10·1 answer
  • Kylee needs to ensure that if a particular client sends her an email while she is on vacation, the email is forwarded to a
    5·1 answer
  • Pro and Cons of Artificial Intelligence in Art <br><br> You must have 3 statements in each
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!