Question: I have the code below but can't seem to get it to work on the zybooks website when entered and in NetBeans it keeps throwing

I have the code below but can't seem to get it to work on the zybooks website when entered and in NetBeans it keeps throwing out errors.

ShoppingCartPrinter.Java

import java.util.Scanner;

public class ShoppingCartPrinter { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.println("Enter two items: "); ItemToPurchase item1 = new ItemToPurchase(); ItemToPurchase item2 = new ItemToPurchase(); System.out.println("Item 1"); System.out.println("Enter the item name: "); item1.setItemName(scanner.nextLine()); System.out.println("Enter the item price: "); item1.setItemPrice(scanner.nextInt()); System.out.println("Enter item quantity: "); item1.setItemQuantity(scanner.nextInt()); System.out.println(); String demoCharacter = scanner.nextLine(); System.out.println("Item 2"); System.out.println("Enter the item name : "); item2.setItemName(scanner.nextLine()); System.out.println("Enter the item price :"); item2.setItemPrice(scanner.nextInt()); System.out.println("Enter the item quantity : "); item2.setItemQuantity(scanner.nextInt()); int totalCostItem1 = item1.getItemQuantity() * item1.getItemPrice(); int totalCostItem2 = item2.getItemQuantity() * item2.getItemPrice(); System.out.println("TOTAL COST " + item1.getItemNae()+ " " + item1.getItemQuantity()+ " @ $" + item1.getItemPrice() + " = " + totalCostItem1 + " " + item2.getItemName() + " " + item2.getItemQuantity() + " @ $" + item2.getItemPrice() + " = " + totalCostItem1+ " " + "Total: $" + (totalCostItem1 + totalCostItem2)); } }

ItemtoPurchase.java

public class ItemToPurchase {

private String itemName; private int itemPrice; private int itemQuantity; public ItemToPurchase() { this.itemName = "none"; this.itemPrice = 0; this.itemQuantity = 0; } public String getItemName() { return itemName; } public void setItemName(String itemName) { this.itemName = itemName; } public int getItemPrice() { return itemPrice; } public void setItemPrice(int itemPrice) { this.itemPrice = itemPrice; } public int getItemQuantity() { return itemQuantity; } public void setItemQuantity(int itemQuantity) { this.itemQuantity = itemQuantity; } }

In the shoppingcartprinter.java code it keeps giving me the following errors:

I have the code below but can't seem to get it to

The two programs are suppose to work together to get the final answers

I would appricate as much help as possible.

Thank you in advance.

Failed to compile ShoppingcartPrinter.ja va:16: error cannot find symbol ItemT Purchase item1 = new ItemT Purchase(); symbol: class ItemToPurchase location: class ShoppingCartPrinter ShoppingCartPrinter.java:16: error: cannot find symbol ItemT Purchase item1 = new ItemT Purchase(); symbol: class ItemToPurchase location: class ShoppingCartPrinter ShoppingCartPrinter.java: 17: error cannot find symbol ItemT Purchase item2 = new ItemT Purchase(); symbol: class ItemToPurchase location: class ShoppingCartPrinter ShoppingcartPrinter.ja va: 17: error: cannot find symbol ItemT Purchase item2 = new ItemT Purchase(); symbol: class ItemToPurchase location: class ShoppingCartPrinter 4 errors

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