
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
![Create a Java class called "Car" with the following data elements: make: String, model: String,
price: double, registration year: int, and engine size:double. Provide default and none default
constructors, and accessor and mutator methods.
Provide a method "roadTax", the method header is {public double roadTax()} that compute the
road annual tax based on the engines Size as follow:
• Engine Size less than or equal 1500 CC the tax is 800 Shekel
• Engine Size greater than 1500CC and less than or equal 2500 CC the tax is 1200 Shekel
• Engine Size greater than 2500CC the tax is 2000 Shekel
Provide a method called "toString", the method header is {public String toString()}, the return
string is a text describing the of the car. An example is given below
Example: BMW, 325, 250000 Shekel, 2020, 2500 CC, 1200 Shekel Annual Road Tax.
Where BMW is the make, 325 is the model, 250000 Shekel is the price, 2020 is the registration
year, and 2500 CC is the engine Size.
Write a Driver class, in the main method create an array of 5 Car objects each car has a
different engine Sizes as follows: 1200CC, 3000 CC, 1800CC, 2000 CC, 2500CC, I left the other
attributes for you to complete.
Then write a method to print the Cars sorted in descending order based on their annual road
tax. The function header as follow: {public static void print(Car[] tmp)}](https://content.bartleby.com/qna-images/question/079ea1e2-7996-4d70-9b44-81fc321611de/95ea2d0b-0eca-43c1-9712-da6fc73c12cf/e0202t2_thumbnail.png)
Transcribed Image Text:Create a Java class called "Car" with the following data elements: make: String, model: String,
price: double, registration year: int, and engine size:double. Provide default and none default
constructors, and accessor and mutator methods.
Provide a method "roadTax", the method header is {public double roadTax()} that compute the
road annual tax based on the engines Size as follow:
• Engine Size less than or equal 1500 CC the tax is 800 Shekel
• Engine Size greater than 1500CC and less than or equal 2500 CC the tax is 1200 Shekel
• Engine Size greater than 2500CC the tax is 2000 Shekel
Provide a method called "toString", the method header is {public String toString()}, the return
string is a text describing the of the car. An example is given below
Example: BMW, 325, 250000 Shekel, 2020, 2500 CC, 1200 Shekel Annual Road Tax.
Where BMW is the make, 325 is the model, 250000 Shekel is the price, 2020 is the registration
year, and 2500 CC is the engine Size.
Write a Driver class, in the main method create an array of 5 Car objects each car has a
different engine Sizes as follows: 1200CC, 3000 CC, 1800CC, 2000 CC, 2500CC, I left the other
attributes for you to complete.
Then write a method to print the Cars sorted in descending order based on their annual road
tax. The function header as follow: {public static void print(Car[] tmp)}
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 2 steps

Knowledge Booster
Similar questions
- Write the definition of a class Player that has the following methods: • An __init__ method that initializes the following attribute variables: o An attribute variable named name , initialized to the empty string. o An attribute variable named score , initialized to the value 0. • A method named set_name that accepts one argument that is assigned to the attribute variable name . • A method named set_score that accepts one argument that is assigned to the attribute variable score . • A method named get_name that accepts no arguments, and returns the value of the attribute variable name . • A method named get_score that accepts no arguments, and returns the value of the attribute variable score .arrow_forwardwrite a class book, which has 3 attributes: title, price, quantity. Write the following methods, (8 points) a. setter/getter methods for each of the 3 attributes. b. __str__ method to display the complete information for the book, including title, price and quantity c. Method sell_copies(), passing the number of copies sold, which will reducethe value of quantity of the book. write the code in python please and thank youarrow_forwardJAVA PROGRAM For this program, you are tasked to implement the Beverage class which has the following private properties: name - a string value volume - this is an integer number which represents its current remaining volume in mL isChilled - this is a boolean field which is set to true if the drink is chilled It should have the following methods: isEmpty() - returns true if the volume is already 0 {toString() - returns the details of the object in the following format: {name} ({volume}mL) {"is still chilled" | "is not chilled anymore"}.Example returned strings: Beer (249mL) is still chilled Water (500mL) is not chilled anymore A constructor method with the following signature: public Beverage(name, volume, isChilled) Getter methods for all the 3 properties. Then, create two final subclasses that inherit from this Beverage class. The first one is the Water class which has the additional private property, type, which is a String and can only be either "Purified", "Regular",…arrow_forward
- JAVA PROGRAM Chapter 7. PC #1. Rainfall Class Write a RainFall class that stores the total rainfall for each of 12 months into an array of doubles. The program should have methods that return the following: • the total rainfall for the year • the average monthly rainfall • the month with the most rain • the month with the least rain Demonstrate the class in a complete program. Main class name: RainFall (no package name) est Case 1 Enter the rainfall amount for month 1:\n1.2ENTEREnter the rainfall amount for month 2:\n2.3ENTEREnter the rainfall amount for month 3:\n3.4ENTEREnter the rainfall amount for month 4:\n5.1ENTEREnter the rainfall amount for month 5:\n1.7ENTEREnter the rainfall amount for month 6:\n6.5ENTEREnter the rainfall amount for month 7:\n2.5ENTEREnter the rainfall amount for month 8:\n3.3ENTEREnter the rainfall amount for month 9:\n1.1ENTEREnter the rainfall amount for month 10:\n5.5ENTEREnter the rainfall amount for month 11:\n6.6ENTEREnter…arrow_forwardT/F 3. All Java classes must contain a main method which is the first method executed when the Java class is called on.arrow_forwardWRITE JAVA CODE FOR THE FOLLOWING Create a class named Pizza with the following data fields: description - of type String price - of type double The description stores the type of pizza (such as sausage and onion). Include a constructor that requires arguments for both fields and a method named display() to display the data. For example, if the description is 'sausage and onion' and the price is '14.99', the display() method should output: sausage and onion pizza Price: $14.99 Create a subclass named DeliveryPizza that inherits from Pizza but adds the following data fields: deliveryFee - of type double address - of type String The description, price, and address are required as arguments to the constructor. The delivery fee is $3 if the pizza ordered costs more than $15; otherwise it is $5. Add a display() method to the DeliveryPizza class. The display() method should print the information from the display() method in the super class (Pizza) in addition to the address and…arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- 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

Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON

Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education

Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY