Question: (JAVA) Create a Phone class with: the following attributes: String brand, String model, double originalPrice, double retailPrice a constructor, input paramters in the order listed

(JAVA)

Create a Phone class with:

the following attributes: String brand, String model, double originalPrice, double retailPrice

a constructor, input paramters in the order listed above

relevant getter and setter methods for each attribute

In the main class:

create a populateList method: this method will create 6 phone objects and add them to the ArrayList 'phonesArrayList' instantiated in the main method. Create 6 phones with the attributes listed below in the order brand, model, originalPrice, retailPrice

Samsung, S9, 900.0, 900.0

Samsung, S10, 950.0, 950.0

Apple, iPhone 8+, 1500.0, 1500.0

Apple, iPhone X, 1550.0, 1550.0

Google,Nexus 9, 575.0, 575.0

Google, Nexus 10, 600.0, 600.0

changePhonePrice method: changes the retailPrice based on the markup.

e.g. if the original price is 500.0 and the markup is 80%, then the retail price becomes 400.0

calculateNewPrice method: filters through ArrayList 'phonesArrayList' and uses the changePhonePrice method based on the conditions below

if the phone is a Samsung, then the samsungMarkup is applied

if the phone is an Apple, then the appleMarkup is applied

if the phone is a Google, then the googleMarkup is applied

In the main method

//call populateList method

//iterate through the arrayList to print out the original price and retail price

//example output: Before markup, the original price for S9 was 900.0 and the sales price was 900.0

//a discount is applied! call calculateNewPrice method

//print out the original price and retail price

//example output: After markup, the original price for S9 was 900.0 and the new price is 720.0

//a clearance sale is happening! call calculateNewPrice method

//print out the original price and retail price

//example output: After clearance, the original price for S9 was 900.0 and the new price is 36.0

For the discount, samsungMarkup = 80%, appleMarkup = 150%, googleMarkup = 50%

For the clearance, samsungMarkup = 5%, appleMarkup = 5%, googleMarkup = 5%

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!