Write the code of a class named EXAM with following description
Private Members;
1. exmCode of type string, 6 characters.
2. exmDescription of type string, 40 characters.
3. noCandidate of type integer.
4. centersReqd (number of centers required) of type integer.
5. A member function CALCNTR( ) to calculate and return the number of
centers as (noCandidates/100+1).
Public Members;
1. A function SCHEDULE( ) to allow user to enter values for exmCode,
xmDescription, noCandidate and call function CALCNTR( ) to calculate the
number of centers.
2. A function DISPXM( ) to allow user to view the content of all the member data.
(The functions should be prototyped within the class and their definitions placed
outside the class)
The square of an integer refers to the result of multiplying the integer with itself once. While the cube of an integer refers to the result of multiplying the integer with itself twice. As long as you know that, you could easily solve this!
Instructions:
Write a program that reads in a set of positive integers and outputs how many times a particular number appears in the list. You may assume that the data set has most 7 numbers
The numbers must be output in increasing order for example:
15402862621528
Create a class to print the area of a rectangle. The class has two methods with the same name but different number of parameters. The method for printing area of rectangle has two parameters which are length and breadth.
Create a class called computers and two classes MyComputer and YourComputer which inherits computer class. Define appropriate fields for the three classes. Create another class processor as a composite class of computer. Write a method which prints the differences between the processors of two computers.
Question 3: (Inheritance)
Create an abstract class called Employee that has an abstract method call computePay() which
computes the total pay per employee using the rate per hour = $50. The method should accept
the number of hours the employee has worked. Create a child class called employeeChild and
provide the implementation. In the main method invoke that method and get the number of hours
worked from the user and pass it to the called method.
Question 2 (Polymorphism)
Mathematically, the area of a rectangle is computed as length * width, the area of a circle is
computed as pi*radius*radius. Given that pi = 3.14, write a Java program with an overloaded
method called getArea() that can compute for the area of a circle or rectangle depending on the
parameters supplied. Illustrate how you will invoke the method in the main method for the two
scenarios.
Question 1: (Inheritance)
Consider a scenario where you have been given three classes, namely Vehicle, Bus, and
School_Bus. The School_Bus class is supposed to inherit all characteristics of both the Vehicle
and the Bus class. Explain and illustrate how you are going to achieve this considering you are using Java programming language.
Write a complete Java program illustrating the difference between instance and static members of class. Indicate with comments where each is used and explain the significance of making the instance or static. (6 marks)
Making use of object orientation write a program that stores and evaluates the total cost for items bought from a supermarket. The cashier should enter the following: - Product code, Price and Quantity. The total price should be evaluated as follows: -
Total cost = Price * Quantity
If the total cost per item is more than 20,000 there is a discount of 14% on that item and a discount of 10% on an item whose total cost is between 10,000 and 20,000. No discount is given on items whose total cost is less than 10,000