1. Create two (2) classes named Car and TestCar. 2. In the Car class, initialize two...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
1. Create two (2) classes named Car and TestCar. 2. In the Car class, initialize two (2) public static variables: MAKE (String, final) and numCars (int). Set their values to "Toyota" and 0, respectively. 3. Declare two (2) empty String instance variables named chassisNo and model. 4. Create a public constructor with a single parameter named model (String). This constructor should: Increment the value of numCars by one. Set the value of chassisNo based on the result of concatenating the String "ch" and the value of numCars. Syntax: chassis No = ch + numCars; Use the this keyword to set the instance variable model equal to the value of the parameter model. Display a message saying "Car manufactured". 5. Create two (2) pairs of getter and setter methods that will allow you to get and set the value of the two (2) instance variables: getModel() and setModel(), getChassis No() and setChassis No() 6. Add a public toString() method that will return and display the car's make, model, and chassis number in separate lines. 7. In the main method of the TestCar class, display the car's make and the initial number of manufactured cars by accessing them from the Cars class. Example: System.out.println("Manufacturer: " + Car.MAKE); 8. Instantiate two (2) Car objects assigning the values "Camry" and "Veloz", respectively. Example: Car car1 = new Car("Camry"); 9. Add two (2) statements to display the data of the two (2) Car objects. Example: System.out.println(car1); 10. Display the total number of cars manufactured by accessing the numCars method. Sample Output: //Initial values Manufacturer: Toyota Number of cars manufactured: 0 Car manufactured //After instantiating first Car object The car is manufactured by: Toyota The model type is Camry The chassis number is ch1 Car manufactured //After instantiating second Car object The car is manufactured by: Toyota The model type is Veloz The chassis number is ch2 //Total number of cars manufactured Number of cars manufactured: 2 1. Create two (2) classes named Car and TestCar. 2. In the Car class, initialize two (2) public static variables: MAKE (String, final) and numCars (int). Set their values to "Toyota" and 0, respectively. 3. Declare two (2) empty String instance variables named chassisNo and model. 4. Create a public constructor with a single parameter named model (String). This constructor should: Increment the value of numCars by one. Set the value of chassisNo based on the result of concatenating the String "ch" and the value of numCars. Syntax: chassis No = ch + numCars; Use the this keyword to set the instance variable model equal to the value of the parameter model. Display a message saying "Car manufactured". 5. Create two (2) pairs of getter and setter methods that will allow you to get and set the value of the two (2) instance variables: getModel() and setModel(), getChassis No() and setChassis No() 6. Add a public toString() method that will return and display the car's make, model, and chassis number in separate lines. 7. In the main method of the TestCar class, display the car's make and the initial number of manufactured cars by accessing them from the Cars class. Example: System.out.println("Manufacturer: " + Car.MAKE); 8. Instantiate two (2) Car objects assigning the values "Camry" and "Veloz", respectively. Example: Car car1 = new Car("Camry"); 9. Add two (2) statements to display the data of the two (2) Car objects. Example: System.out.println(car1); 10. Display the total number of cars manufactured by accessing the numCars method. Sample Output: //Initial values Manufacturer: Toyota Number of cars manufactured: 0 Car manufactured //After instantiating first Car object The car is manufactured by: Toyota The model type is Camry The chassis number is ch1 Car manufactured //After instantiating second Car object The car is manufactured by: Toyota The model type is Veloz The chassis number is ch2 //Total number of cars manufactured Number of cars manufactured: 2
Expert Answer:
Answer rating: 100% (QA)
Carjava java public class Car public static final String MAKE Toyota public static int nu... View the full answer
Related Book For
International Marketing And Export Management
ISBN: 9781292016924
8th Edition
Authors: Gerald Albaum , Alexander Josiassen , Edwin Duerr
Posted Date:
Students also viewed these programming questions
-
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace DES1_DeckAndMenu { internal class Program { static void Main(string[]...
-
ENSURE WORK IS ORIGINAL OR I REJECT AND REPORT YOU TON THE SUPPORT INSTANTLYThe end result does now not should be taken care of. You may additionally expect n 6 length(xs). [Hint: Function least is a...
-
Amandeep, a graduate of Cambrian Colleges Business Program, found a job as an online marketing specialist for Tangerine Bank. Within a year, he had saved {A} and decided to buy a new car but was not...
-
(a) Which of these three lines represents the effect of concentration on the percent ionization of a weak acid? (b) Explain in qualitative terms why the curve you chose has the shape it does. ZI Acid...
-
Qualitative methods of forecasting include: a) Sales force composite. b) Jury of executive opinion. c) Consumer market survey. d) Exponential smoothing. e) All except (d).
-
Does spring mounting always reduce the vibration of the foundation of a machine?
-
Consider the following transactions that occurred in September 2012 for Aquamarines, Inc. Sep 3 Purchased inventory on terms 1/15, n/eom, $5,000. 4 Purchased inventory for cash of $1,700. 6 Returned...
-
Women's best is a new up and coming fitness facility discovered in the 21st century that is centered around the physical, emotional and mental wellness of women specifically. Women's best is fully...
-
List two metrics currently used in your professional field that are reviewed periodically, and explain how they are used to drive change. Describe the process of developing an internal operational...
-
Identify the benefits of BCM that are easy to quantify and those that are not easy to quantify.
-
Once completed, why would a BCP ever change?
-
Why should senior management rather than IT managers have final approval over the IT Disaster Recovery Plan?
-
To paraphrase the American humorist Mark Twain, reports of the coal industrys death have been greatly exaggerated. The coal industry is clearly in decline but appears to be far from dead. Globally,...
-
Why are comprehensive checklists and questionnaires beneficial during the site inspection and management interview process?
-
An instrument has a component subject to random failure. If the instrument is operating correctly at a given point in time, then with probability 0.15 it will fail during the next 20 minute period....
-
The roof of a refrigerated truck compartment is of composite construction, consisting of a layer of foamed urethane insulation (t2 = 50 mm, ki = 0.026 W/m K sandwiched between aluminum alloy panels...
-
Calculate the volatility and the current price of oil futures implied by the call 1600 August and the call 1700 August of Figure 19.8 by using the Black-Scholes formula with \(T=.25\). OIL CRUDE OIL...
-
Consider a continuous-time environment, with \(e\) as a variable outside of the market. (a) Suppose the final payoff is \(V\left(x_{e}, T ight)=x_{e}(T)\). Find \(V\left(x_{e}, t ight)\). (b) Find a...
-
Mr. Smith wants to buy a car and is deciding between brands A and B. Car A costs \(\$ 20,000\), and Mr. Smith estimates that at the rate he drives he will sell it after 2 years and buy another of the...
Study smarter with the SolutionInn App