Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help writing a program for #2 in java! 2. Design a Car class that has the following data fields: color (String) year (int) maker

Need help writing a program for #2 in java!

image text in transcribed

2. Design a Car class that has the following data fields: color (String) year (int) maker (String) speed (double) Define the following methods in the class: 2 constructors: the first constructor will initialize all data variables to default values (select you own default values for each data variables); the second constructor will use input arguments to initialize its data variables; Methods to get individual data fields; Methods to change speed of a car object: O speedUp() to increase the speed by 10 miles per hour until it reaches the maximum speed which is 160; o slowDown () to decrease the speed by 10 miles per hour until it reaches 0; Write a Demo/Test program to demonstrate how the class works: get input from console which include maker, color, year, and speed; create a car object using input arguments; display all internal information in a car; call the speedUp() method five times and the slowDown() method four times, display car's final speed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions