1 / 6

Exercise 12.2

Exercise 12.2. Write a program that Creates an Item instance named Tuna with price $2.45 Purchases 200 units for a total of $250 Sells 50 units Sells 25 units for a total of $30 Purchases 100 units for a total of $175 Outputs unit cost price. Exercise 12.3. Write a program that

loiswatson
Download Presentation

Exercise 12.2

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Exercise 12.2 • Write a program that • Creates an Item instance named Tuna with price $2.45 • Purchases 200 units for a total of $250 • Sells 50 units • Sells 25 units for a total of $30 • Purchases 100 units for a total of $175 • Outputs unit cost price

  2. Exercise 12.3 • Write a program that • Creates a Fresh instance called “Pacific Salmon”, with any item number, a price of $20, and an expiry date three weeks from now • Creates a Fresh instance called “Atlantic Salmon”, with the same item number as above, a price of $25, and an expiry date 20 days from now • Outputs the return of the equals method invoked on one passing the other as argument • Outputs the return of the toString method for the two items

  3. Exercise 12.4 • The object reference x was declared and assigned as follows • Write a code fragment that changes the credit rating to AA Contact x = new Client (“Adam”, “Toronto”, “AA-”);

  4. Exercise 12.6 • Write a program that • Creates an Item instance named Tuna with price $2.45 • Creates a Supplier instance named “Adam” with any address such that it supplies the above item at $1.75 a unit

  5. Exercise 12.9 • Starting from a randomly chosen inventory collection, write a program that lists the fresh items and their expiry dates

  6. Exercise 12.17 • Starting from a randomly chosen contacts collection, write a program that determines whether any item has more than one supplier

More Related