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
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started