Create an Investment class that contains fields to hold the initial value of an investment, the
current value, the profit (calculated as the difference between current value and initial value),
and the percent profit (the profit divided by the initial value). Include a constructor that requires
initial and current values and a display function. Create a House class that includes fields for
street address and square feet, a constructor that requires values for both fields, and a display
function. Create a HouseThatIsAnInvestment class that inherits from Investment and House. It
includes a constructor and a display function that calls the display functions of the parents
java inheritance programs of example music composition
Create a class named MusicalComposition that contains fields for title, composer, and year written. Include a constructor that requires all three values and an appropriate display function. The child class NationalAnthem contains an additional field that holds the name of the anthem’s nation. The child class constructor requires a value for this additional field. The child class also contains a display function. Write a main() function in class MusicDemo that instantiates objects of each class and demonstrates that the functions work correctly.
Rohan was asked by his teacher to develop a program which takes in a dynamic user input and prints all the prime numbers till that number and then prints all the composite numbers till that number. Help him out by developing the program to do so
Sam runs a local musical equipment store in your neighbourhood. He has contracted you to create an interactive application that will assist him with customer purchases. Create a class named Customer Purchases that will contain get and set methods for a customer number, first name, surname, product, price and quantity. Create a separate class called Printing that will include a method called Print Details, that will print the Customer Invoice. In the Printing class include another method called Customer Purchase Report which will display the following information: REPORT OPTION PERCENTAGE TAX 15% COMMISSION 8.5% DISCOUNT 10% TOTAL (Price + Tax) – (Discount + Commission)
Write a Java code Using Arraylist and Inheritance.
Input Sample
Enter number of presidents: 5
Enter class president id: 10
Enter class president id: 20
Enter class president id: 30
Enter class president id: 40
Enter class president id: 50
Output :
power on class 10
power on class 20
power on class 30
power on class 40
power on class 50
power on school
Best president id: 10
or
Input
Enter number of presidents: 2
Enter class president id: 45
Enter class president id: 23
output :
power on class 45
power on class 23
power on school
Best president id: 45
or
Input:
Enter number of presidents: 0
output:
power on school
Create a class named Person , which contains . A function named print ( ) Two data fields i.e. person Name and age A class named Patient inherits Person class , which contains Two data fields i.e. disease Type and recommended Medicine Overridden function print ( ) to display all details relevant to a patient A class named Medicare Patient inherited from class Patient , which holds A data field representing the name of the hospital A data filed representing the name of the ward A data field representing room number Overridden function print ( ) isplay all details relevant to . . In the main function , create instances of derived classes to access respective print ( ) function using dynamic binding .
Consider a class Computer having . Two fields ( i.e. companyName , price ) and A single function named show ( ) A class named Desktop inherits Computer class and adds fields representing color , monitor size , and processor type and Override function named show ( ) to display values of its all attributes . A class named Laptop inherits Computer class and adds fields representing color , size , weight , and processor type and Override function named show ( ) to display values of its all attributes . Write a main ( ) function that instantiates objects of derived classes to access respective show ( ) function using dynamic binding .
Write an interactive program that is a dialogue between two people. The dialogue should include strings, integers, and double numbers. Make the program more useful by implementing some math calculation. Also, include two types of comments at the proper places