Question: In Java. I cannot get the total to output. This program extends the earlier Online shopping cart program. ( Consider first saving your earlier program

In Java. I cannot get the total to output.
This program extends the earlier "Online shopping cart" program. (Consider first saving your earlier program).
(1) Extend the ItemToPurchase class per the following specifications:
Private fields
string itemDescription - Initialized in default constructor to "none"
Parameterized constructor to assign item name, item description, item price, and item quantity (default values of 0).(5 pt)
Public member methods
setDescription() mutator & getDescription() accessor (5 pts)
printItemCost()- Outputs the item name followed by the quantity, price, and subtotal
printItemDescription()- Outputs the item name and description
Ex. of printItemCost() output:
Bottled Water 10 @ $1= $10
Ex. of printItemDescription() output:
Bottled Water: Deer Park, 12 oz.
(2) Create two new files (10 pts):
ShoppingCart.java - Class definition
ShoppingCartManager.java - Contains main() method
Build the ShoppingCart class with the following specifications. Note: Some can be method stubs (empty methods) initially, to be completed in later steps.
Private fields (10 pts)
String customerName - Initialized in default constructor to "none"
String currentDate - Initialized in default constructor to "January 1,2016"
ArrayList cartItems
Default constructor
Parameterized constructor which takes the customer name and date as parameters (2 pts)
Public member methods
getCustomerName() accessor (1 pt)
getDate() accessor (1 pt)
addItem()
Adds an item to cartItems array. Has parameter ItemToPurchase. Does not return anything.
removeItem()
Removes item from cartItems array. Has a string (an item's name) parameter. Does not return anything.
If item name cannot be found, output this message: Item not found in cart. Nothing removed.
modifyItem()(2 pts)
Modifies an item's description, price, and/or quantity. Has parameter ItemToPurchase. Does not return anything.
If item can be found (by name) in cart, check if parameter has default values for description, price, and quantity. If not, modify item in cart.
If item cannot be found (by name) in cart, output this message: Item not found in cart. Nothing modified.
getNumItemsInCart()(3 pts)
Returns quantity of all items in cart. Has no parameters.
getCostOfCart()(3 pts)
Determines and returns the total cost of items in cart. Has no parameters.
printTotal()
Outputs total of objects in cart.
If cart is empty, output this message: SHOPPING CART IS EMPTY
printDescriptions()
Outputs each item's description.
Ex. of printTotal() output: John Doe's Shopping Cart - February 1,2016
Number of Items: 8
Nike Romaleos 2 @ $189= $378
Chocolate Chips 5 @ $3= $15
Powerbeats 2 Headphones 1 @ $128= $128
Total: $521
MY CODE SO FAR:
package onlineShoppingCart;
import java.util.Scanner;
public class ItemToPurchase {
// Private fields
private String itemName;
private String itemDescription;
private int itemPrice;
private int itemQuantity;
// Default constructor
public ItemToPurchase(){
this.itemName = "none";
this.itemDescription = "none";
this.itemQuantity =0;
this.itemPrice =0;
}
// Parameterized constructor to assign name, description, price, and quantity
public ItemToPurchase(String itemName, String itemDescription, int itemPrice, int itemQuantity){
this.itemName = itemName;
this.itemDescription = itemDescription;
this.itemPrice = itemPrice;
this.itemQuantity = itemQuantity;
}
// Public member methods
public String getItemDescription(){
return itemDescription;
}
public void setItemDescription(String itemDescription){
this.itemDescription = itemDescription;
}
public void printItemCost(){
System.out.println(itemName +""+ itemQuantity +" @ $"+ itemPrice +"= $"+(itemQuantity * itemPrice));
}
public void printItemDescription(){
System.out.println(itemName +": "+ itemDescription);
}
public String getName(){
return itemName;
}
public void setName(String itemName){
this.itemName = itemName;
}
public int getPrice(){
return itemPrice;
}
public void setPrice(int itemPrice){
this.itemPrice = itemPrice;
}
public int getQuantity(){
return itemQuantity;
}
public void setQuantity(int itemQuantity){
this.itemQuantity = itemQuantity;
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Finance Questions!