I have this problem and I keep getting a error. "ShoppingCartPrinter.java:29: error: reached end of file while parsing } ^ 1 error. " Idk what to do.
I have this problem and I keep getting a error. "ShoppingCartPrinter.java:29: error: reached end of file while parsing } ^ 1 error. " Idk what to do. This is my code.
public class ItemToPurchase {
public class ItemToPurchase
{
private String itemName;
private int itemPrice;
private int itemQuantity;
public ItemToPurchase()
{
this.itemName = "none";
this.itemPrice = 0;
this.itemQuantity = 0;
}
public ItemToPurchase(String itemName, int itemPrice, int itemQuantity)
{
this.itemName = itemName;
this.itemPrice = itemPrice;
this.itemQuantity = itemQuantity;
}
public void setName(String itemName)
{
this.itemName = itemName;
}
public String getName()
{
return itemName;
}
public void setPrice(int itemPrice)
{
this.itemPrice = itemPrice;
}
public int getPrice()
{
return itemPrice;
}
public void setQuantity(int itemQuantity)
{
this.itemQuantity = itemQuantity;
}
public int getQuantity()
{
return itemQuantity;
}
}
class ShoppingCartPrinter
{
public static void main(String[] args)
{
Scanner scnr = new Scanner(System.in);
String item1 = "";
String item2 = "";
int price1 = 0;
int price2 = 0;
int quantity1 = 0;
int quantity2 = 0;
ItemToPurchase itemInfo1 = new ItemToPurchase();
ItemToPurchase itemInfo2 = new ItemToPurchase();
System.out.println("Item 1");
System.out.println("Enter the item name:");
itemInfo1.setName(scnr.nextLine());
System.out.println("Enter the item price:");
itemInfo1.setPrice(scnr.nextInt());
System.out.println("Enter the item quantity:");
itemInfo1.setQuantity(scnr.nextInt());
System.out.println();
System.out.println("Item 2");
itemInfo2.setName(scnr.nextLine());
System.out.println("Enter the item name:");
itemInfo2.setName(scnr.nextLine());
System.out.println("Enter the item price:");
itemInfo2.setPrice(scnr.nextInt());
System.out.println("Enter the item quantity:");
itemInfo2.setQuantity(scnr.nextInt());
System.out.println();
System.out.println("TOTAL COST");
System.out.println(itemInfo1.getName() + " " + itemInfo1.getQuantity() + " @ $" + itemInfo1.getPrice() + " = $" + (itemInfo1.getPrice() * itemInfo1.getQuantity()));
System.out.println(itemInfo2.getName() + " " + itemInfo2.getQuantity() + " @ $" + itemInfo2.getPrice() + " = $" + (itemInfo2.getPrice() * itemInfo2.getQuantity()));
System.out.println();
System.out.println("Total: $" + ((itemInfo1.getPrice() * itemInfo1.getQuantity()) + (itemInfo2.getPrice() * itemInfo2.getQuantity())));
}
}
public void printItemPurchase() {
System.out.println(itemQuantity + " " + itemName + " $" + itemPrice +
" = $" + (itemPrice * itemQuantity));
}
}



Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images









