Question: 1.Create a folder named LastName_FirstName (ex.Reyes_Mark) in your local drive. 2. Create a project named Labexer2. Set the project location to your own folder. 3.

1.Create a folder named LastName_FirstName (ex.Reyes_Mark) in your local drive.
2. Create a project named Labexer2. Set the project location to your own folder.
3. Construct a simple purchasing program based on the UML Class Diagram below.

Labexer2
-itemName:String
-itemPrice:double
-itemQuantity:int
-amountDue:double

+setItemName(Stribg newItemName):void
+setTotalCost(int quantity,diuble price):void
+getitemName():String
+getTotalCost():double
+readinput():void
+writeOutput():void
Note: the readinput () method will be used to accept user input through the Scanner class. This is done by:
a.Writing import java.util.*; on top of the code before the line for the class name
b.Instantiating an object of the scanner class, Scanner s = new Scanner(System.in);
c.Storing the input to the variable name based on data type
For string: s.nextLine()
For int: s.nextInt()
For double: s.nextDouble()
the write output () method will be used to display an output similar to the sample below.
Your are purchasing 3 bags (s) at 1,745.t each
Sample output
Enter the name of the item you are purchasing
bag
Enter the quantity and price separated by a space.
3 1475.50
You are purchasing 3 bag(s) at 1475.5 each
Amount due is 4426.50

Step by Step Solution

3.52 Rating (165 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Labexer2java import javautilScanner public class Labexer2 String itemName double itemPrice int itemQ... View full answer

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 Programming Questions!