Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help me with this problem.Programming is based on the Java language. 1) Create a class called Item that can be used within a Java

Please help me with this problem.Programming is based on the Java language.

image text in transcribed

1) Create a class called Item that can be used within a Java application for a store to represent the items that are sold in the store. An item should include three pieces of information: item number (integer type), quantity (integer type) and item price (double type). The class Item contains a constructor to initialize the 3 instance variables. The quantity must be between 1 and 1000 and therefore the quantity attribute should be private. Write a set and a get methods for the quantity instance variable. You can follow the simple steps: -- Start NetBeans (or Eclipse if you prefer it). -- Start a new Java project call it Item (make sure your Java source code file is named Item.java) -- Start writing the code for the class Item in the file Item.java --run the code to check if you have any errors. ***note: Since our class is called Item, the Java source program file should be named Item.java. -- you can fix and remove the errors if any. -- after you enter the code and correct errors run the program by selecting run from the top menu. ***note: since your class does not have a main() method, there is not any output or functionality at this point. For this part, submit the source code and screen shot showing that there are no errors. Write the driver class for the Item class (you can call it Item Test). In class Item Test initialize only two instances (2 objects) with the following values/initialization: Item number 101, Item quantity 85, Item price: 29.50 Item number 110, Item quantity 250, Item price: 7.99 The class Item Test prints/outputs the item number, quantity and price with a nice readability. Submit the complete source code for this part and (screen shots) sample output (note: put both classes in one file). {hint: Item al = new Item(101, 85, 29.50); } Update the class Item by adding one more (fourth) attribute (instance variable) for item description of type String (class Item has now four attributes). Update class Item Test to output item description as well. Also instantiate one more object. For this part, submit complete source code for both classes including the updates: submit also screen shots of the output (again, both classes Item and Item Test are in one file called ItemTest.java). Update the application so that it instantiates/creates 3 more objects of Item (now the total is 6). Fill the values of these five items/objects. Print item description and item price for each one of the 5 instances (no need to print item Id number or quantity). Submit the complete source program with sample output (screenshots). Update the class Item by adding a method called total cost in class Item that calculates the total cost of the item by multiplying quantity by the price (note: total cost of an item is not attribute, it is a method. For example, if one of the items/instances has item quantity 10 and item price 12.50 then its total cost will be $125.0 calculated by the method). Also update the driver class so it outputs item number, quantity, price, and totalCost for each of the 6 items. Tud

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Database Systems For Advanced Applications 17th International Conference Dasfaa 2012 Busan South Korea April 2012 Proceedings Part 1 Lncs 7238

Authors: Sang-goo Lee ,Zhiyong Peng ,Xiaofang Zhou ,Yang-Sae Moon ,Rainer Unland ,Jaesoo Yoo

2012 Edition

364229037X, 978-3642290374

More Books

Students also viewed these Databases questions

Question

Identify the cause of a performance problem. page 363

Answered: 1 week ago