this is actually the activity. i dont know if i should post this or not but im just really desperate. im so sorry. please help me.
how do i code the void ones?
Exercise2 |
__________________________________________________|
- itemName: String |
- itemPrice: double |
- itemQuantity: int |
- amountDue: double |
__________________________________________________|
+ stetItemName(String newItemName): void |
+ setTotalCost(int quantity, double 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 writeOutput() method will be used to display an output similar to the sample below.
You are purchasing 3 bag(s) at 1999.5 each.
Sample output:
Enter the name of the item you are purchasing.
bag
Enter the quantity and price separated by a space.
3 2000.50
You are purchasing 3 bag(s) at 2000.5 each.
Amount due is 6001.50