Question: I ran my code 2 different times and I must be going wrong somewhere, can somebody help me? (This is Java and we can only

I ran my code 2 different times and I must be going wrong somewhere, can somebody help me? (This is Java and we can only use NETBEANS)

I ran my code 2 different times and I must be goingwrong somewhere, can somebody help me? (This is Java and we can

Instructions Write a program that does the following: 1) Create a class called Toy a) Define at three private data members that makes sense for a class called Toy. i) A string that is the name of the toy ii) You decide what this data member represents and what is the appropriate data type iii) A double representing the price of the toy b) Create a Constructor that initializes only the first and second data members using arguments i) Take the argument passed in for the name of the toy, make it uppercase using a String method, and assign it to the appropriate data member. ii) Initialize the second data member with the second argument iii) Create a random double in the range of [10.75, 20.5) and assign it the third data member representing the price of the toy. (Note, after formatting for output you can get 20.50.) c) Write the one get method to retrieve the values of the third data member as type double. d) Write one set method to set the value of the third data member. e) Write the toString method as described in class using example below. The price must be output in Currency using the FormatNumber class. In main method f) Create an instance of the Toy class passing two arguments as described above g) Call the get method for the price to retrieve the current price. h) Output the current price formatted for currency. i) Decrease the current price by 20% j) Call the set method to update the price with the new value you calculated. k) Call the toString method and output the String it returns for the instance variables. 2) Example Output. Your goal is not to make your output exactly the same as mine, as long as you follow the format for toString() as explained in chapter 3. Price before decrease: $10.91 Toy name: JUMP ROPE Color: green sparkles Price: $8.73

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!