
Write code for an Invoice class for a car sale. Printing an object of the Invoice should print the
details about the seller, the buyer, the dealer, the date of transaction, the car being sold, the purchase and
selling price, the commission earned by the dealer, sales tax, and the total price of the car (calculated given
the details in Question 3 part 3). A generation of the invoice object should set the isSold variable of the car
class to true. You do not need to write code for any other classes
Question 3 part 3 is given Below
[
Question 3:
1. Explain the importance of method signature in method overriding.
2. The system might want to use an overridden method (function) with a common signature across the relevant classes Seller, Dealer, Buyer, and distinct classes Car and Invoice for maintaining the finances. Details of the classes can be seen in Table 1. Explain with proper syntax as to how this can be achieved using object-oriented
3. Write Java code (for the methods only) that implements the method with the same signature for each class with the following details:
a. Calculates the commission earned by the dealer. A dealer charges 1% commission each to the buyer and seller on sale price of the car.
b. The profit or loss for the seller. A seller earns profit (incurs loss) computed as the difference between the sale and purchase price of the car. Sales Tax is deducted at the
rate of 17% on the profit earned. No sales tax is charged in case of loss. The method should display an appropriate message accordingly.
c. The total amount paid by the buyer.
with code
import java.util.*;
class Car{ //class car
String[] name;
int reg_number,eng_number, chassis_num,status;
String[] city, model, color, date_reg,date_arr,type;
float price;
float abstract calculate (float price);
}
class Dealer extends Car{ //inherits from Car
String[] deal_name, deal_id, deal_add, deal_pno;
float dealer_com ;
float abstract calculate (float price)
{ dealer_com= 0.01*price + 0.01*price;
}
return dealer_com;
}
class person {
String[] name, address, p_no, email;
}
class Seller extends Car{ //inherits from Car
person p= new person();
float seller_price,sale_tax;
float profit;
float abstract calculate (float price)
{
if(purchase_price>sale_price)
{
profit= purchase_price-sale_price;
sale_tax=sale_tax-0.17*profit;
return profit;
}
else
return price;
}
}
class Buyer extends Car{ //inherits from Car
person p= new person();
float total_amount;
int f;
seller s= new seller();
float abstract calculate (float price)
{ f=s.calculate(price);
if(f==price)
return price;
else
retun price+f;
}
}
class Invoice{
public static void main(String[] args)
{
}
}
]

Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 1 images

- Assignment You work at the Computer Science 201L Library, and your boss just bought a bunch of new books for the library! All of the new books need to be cataloged and sorted back on the shelf. You don’t need to keep track of what customer has the book or not, just whether they are checked in or out. Objects You need to create a class called LibraryBook. It needs to have the following member variables, stored privately: string title, string author, and string ISBN. You also need to have a Boolean to store its status whether it’s checked out or not. Call this variable checkedOut. Create a header file and a .cpp file for the LibraryBook class. Call it LibraryBook.cpp and LibraryBook.h For functions, this library book class needs to have: A default constructor setting all strings blank and the checked out status to false A constructor setting all strings through the parameters (title, author, ISBN), and setting the checked out status to false. “Getters” to get the values from the…arrow_forwardUse the mkdir command to add a directory named test2 in your home directory. Use one command to verify that the copy of /etc/passwd was successfully made to ~/test2/passwd.bak while also indicating that it is not empty. The output of this command must consist of only two short lines. Use the cat command to review the contents of the ~/test2/passwd.bak What is the code line for this in UBUNTU?arrow_forwardPart A Create a FitnessTracker class that includes three data fields for a fitness activity: a String for the name of the activity as activity, an int for the number of minutes spent participating as minutes, and a LocalDate for the date as date. Create a default constructor that automatically sets the activity to running, the minutes to 0, and the date to January 1 of the current year. Overload the constructor so it receives parameters for each of the fields and assigns them appropriately. Includes methods to get each data field. Part B Create an application that instantiates two FitnessTracker objects. Prompt the user for values for one object, and pass those values to the three constructor parameters. Retain the default constructor values for the other object. Display the values for each object. An example of the program is shown below: Enter activity >> swimming Enter minutes spent swimming >> 90 Enter month >> 2 Enter day >> 24 Enter year >> 2021…arrow_forward
- An object of the class Timer is used to indicate when a certain amount of time (in seconds) has elapsed, after which it provides a “DING". The required data field is remainingTime which is the number of seconds until the “DING". When a Timer object is constructed, it is set with the desired number of seconds. When the timer "ticks", it is one second closer to the "DING". This is represented with the tick) method. The dingChecko method indicates whether the timer should be "DINGING". Provide the code for the constructor method, and the methods getRemainingTime), tick(), and dingCheck). public class Timer // Methods // Data private int KeuainingTinei }arrow_forwardO Challenge task Write the code of the Constructors and Distructor for the following class 1-Write the code for the empty constructor, that sets X, Y to 0, and prints "Constructor 1 2-Write the code for the parameterized constructor, that takes two integers AB and assigns X A Y=B. and prints the Sentance "Constructor 2 3-Write the code for the Distructor that prints the Sentance "Distruct" followed by the value of X, Y Constraints 5 Input Format the input is two integers E. Output Format as shown in Test case Sample #1 Input 57 Output Constructor 1 Constructor 2 Constructor 1 Destruct 0,0 Destruct 5,7 Destruct 0,0arrow_forwardWrite a member method for the Team class named : calculatePercentage that it will calculate and return the winning percentage of a team. The winning percentage is calculated as follows: wins / ( wins + losses)arrow_forward
- Complete the Car class by creating an attribute purchase_price (type int) and the method print_info() that outputs the car's information. Ex: If the input is: 2011 18000 2018 where 2011 is the car's model year, 18000 is the purchase price, and 2018 is the current year, then print_info() outputs: Car's information: Model year: 2011 Purchase price: $18000 Current value: $5770 Note: print_info() should use two spaces for indentation.arrow_forwardThere are two types of data members in a class: static and non-static. Provide an example of when it might be useful to have a static data member in the actual world.arrow_forwarda constructor that takes in an int, a string, and a double, constructor will assign them to the ID, name, and Averageinstance variables, then a no-argument (zero-parameter) constructor that will set the ID to the name to “No name assigned” and the Average to –1.0. With an accessor method for the name variable and a mutator method for the average variable. a toString() method that will display all three instance variables on a single line, with a " | " between each one. and then an equals() method that returns true only if all three instance variables are equalarrow_forward
- Design a Ship class that the following members: A field for the name of the ship (a string). A field for the year that the ship was built (a string). A constructor and appropriate accessors and mutators. A toString method that displays the ship’s name and the year it was built. Design a CruiseShip class that extends the Ship class. The CruiseShip class should have the following members: A field for the maximum number of passengers (an int). A constructor and appropriate accessors and mutators. A toString method that overrides the toString method in the base class. The CruiseShip class’s toString method should display only the ship’s name and the maximum number of passengers. Design a CargoShip class that extends the Ship class. The CargoShip class should have the following members: A field for the cargo capacity in tonnage (an int). A constructor and appropriate accessors and mutators. A toString method that overrides the toString method in the base class. The…arrow_forwardThis is Phython Programmingarrow_forwardCould you please help me with this chapter 6 number 15 Programming challenge from Starting out with Java Gaddis 7th edition book. Thank youarrow_forward
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY





