public class ItemToPurchase {     private String itemName;     private int itemPrice;     private int itemQuantity;     // Default constructor     public ItemToPurchase() {         itemName = "none";         itemPrice = 0;         itemQuantity = 0;     }     // Mutator for itemName     public void setName(String itemName) {         this.itemName = itemName;     }     // Accessor for itemName     public String getName() {         return itemName;     }     // Mutator for itemPrice     public void setPrice(int itemPrice) {         this.itemPrice = itemPrice;     }     // Accessor for itemPrice     public int getPrice() {         return itemPrice;     }     // Mutator for itemQuantity     public void setQuantity(int itemQuantity) {         this.itemQuantity = itemQuantity;     }     // Accessor for itemQuantity     public int getQuantity() {         return itemQuantity;     } } import java.util.Scanner; public class ShoppingCartPrinter {    public static void main(String[] args) {       Scanner scnr = new Scanner(System.in);      // Creating instances of ItemToPurchase         ItemToPurchase item1 = new ItemToPurchase();         ItemToPurchase item2 = new ItemToPurchase();         // Setting properties for item1         item1.setName("Laptop");         item1.setPrice(800);         item1.setQuantity(2);         // Setting properties for item2         item2.setName("Mouse");         item2.setPrice(20);         item2.setQuantity(5);         // Displaying item information         System.out.println("Item 1:");         System.out.println("Name: " + item1.getName());         System.out.println("Price: $" + item1.getPrice());         System.out.println("Quantity: " + item1.getQuantity());         System.out.println("Total Cost: $" + item1.getPrice() * item1.getQuantity());         System.out.println();         System.out.println("Item 2:");         System.out.println("Name: " + item2.getName());         System.out.println("Price: $" + item2.getPrice());         System.out.println("Quantity: " + item2.getQuantity());         System.out.println("Total Cost: $" + item2.getPrice() * item2.getQuantity());     } }

Systems Architecture
7th Edition
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Stephen D. Burd
Chapter4: Processor Technology And Architecture
Section: Chapter Questions
Problem 3RP
icon
Related questions
Question

public class ItemToPurchase {
    private String itemName;
    private int itemPrice;
    private int itemQuantity;

    // Default constructor
    public ItemToPurchase() {
        itemName = "none";
        itemPrice = 0;
        itemQuantity = 0;
    }

    // Mutator for itemName
    public void setName(String itemName) {
        this.itemName = itemName;
    }

    // Accessor for itemName
    public String getName() {
        return itemName;
    }

    // Mutator for itemPrice
    public void setPrice(int itemPrice) {
        this.itemPrice = itemPrice;
    }

    // Accessor for itemPrice
    public int getPrice() {
        return itemPrice;
    }

    // Mutator for itemQuantity
    public void setQuantity(int itemQuantity) {
        this.itemQuantity = itemQuantity;
    }

    // Accessor for itemQuantity
    public int getQuantity() {
        return itemQuantity;
    }
}

import java.util.Scanner;

public class ShoppingCartPrinter {
   public static void main(String[] args) {
      Scanner scnr = new Scanner(System.in);

     // Creating instances of ItemToPurchase
        ItemToPurchase item1 = new ItemToPurchase();
        ItemToPurchase item2 = new ItemToPurchase();

        // Setting properties for item1
        item1.setName("Laptop");
        item1.setPrice(800);
        item1.setQuantity(2);

        // Setting properties for item2
        item2.setName("Mouse");
        item2.setPrice(20);
        item2.setQuantity(5);

        // Displaying item information
        System.out.println("Item 1:");
        System.out.println("Name: " + item1.getName());
        System.out.println("Price: $" + item1.getPrice());
        System.out.println("Quantity: " + item1.getQuantity());
        System.out.println("Total Cost: $" + item1.getPrice() * item1.getQuantity());
        System.out.println();

        System.out.println("Item 2:");
        System.out.println("Name: " + item2.getName());
        System.out.println("Price: $" + item2.getPrice());
        System.out.println("Quantity: " + item2.getQuantity());
        System.out.println("Total Cost: $" + item2.getPrice() * item2.getQuantity());
    }
}

Input
Your output starts
with
Expected output
starts with
Chocolate Chips
3
1
Bottled Water
1
10
Item 1:
Name: Laptop
Price: $8004
Quantity: 2
Total Cost: $1600
Item 2:
Name: Mouse
Price: $20<
Quantity: 5
Total Cost: $100
Item 1
Enter the item name:
Enter the item price:
Enter the item quantity:
Item 2
Enter the item name:
Enter the item price:
Enter the item quantity:
Transcribed Image Text:Input Your output starts with Expected output starts with Chocolate Chips 3 1 Bottled Water 1 10 Item 1: Name: Laptop Price: $8004 Quantity: 2 Total Cost: $1600 Item 2: Name: Mouse Price: $20< Quantity: 5 Total Cost: $100 Item 1 Enter the item name: Enter the item price: Enter the item quantity: Item 2 Enter the item name: Enter the item price: Enter the item quantity:
Input
Your output
Expected output
Chocolate Chips
3
1
Bottled Water
1
10
Item 1:4
Name: Laptop
Price: $800<
Quantity: 2
Total Cost: $1600
له
Item 2:4
Name: Mouse
Price: $204
Quantity: 5
Total Cost: $100
Item 14
Enter the item name:
Enter the item price:<
Enter the item quantity:
Item 2
Enter the item name:
Enter the item price:
Enter the item quantity:
TOTAL COST
Chocolate Chips 1 @ $3 = $34
Bottled Water 10 @ $1 = $10
Total: $134
Transcribed Image Text:Input Your output Expected output Chocolate Chips 3 1 Bottled Water 1 10 Item 1:4 Name: Laptop Price: $800< Quantity: 2 Total Cost: $1600 له Item 2:4 Name: Mouse Price: $204 Quantity: 5 Total Cost: $100 Item 14 Enter the item name: Enter the item price:< Enter the item quantity: Item 2 Enter the item name: Enter the item price: Enter the item quantity: TOTAL COST Chocolate Chips 1 @ $3 = $34 Bottled Water 10 @ $1 = $10 Total: $134
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Unreferenced Objects
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning