I need a shoppingcartmanager.java that contains a main method for this code in java
Itemtopurchase.java
public class ItemToPurchase {
// instance variables
private String itemName;
private String itemDescription;
private int itemPrice;
private int itemQuantity;
// default constructor
public ItemToPurchase() {
this.itemName = "none";
this.itemDescription =
"none";
this.itemPrice = 0;
this.itemQuantity = 0;
}
public ItemToPurchase(String itemName, int itemPrice,
int itemQuantity,String itemDescription) {
this.itemName = itemName;
this.itemDescription =
itemDescription;
this.itemPrice = itemPrice;
this.itemQuantity =
itemQuantity;
}
// method to set name of the item
public void setName(String name) {
itemName = name;
}
// method to set price of the item
public void setPrice(int price) {
itemPrice = price;
}
// method to set quantity of the item
public void setQuantity(int quantity) {
itemQuantity = quantity;
}
public void setDescription(String description) {
itemDescription =
description;
}
// method to get name of the item
public String getName() {
return itemName;
}
// method to get price of the item
public int getPrice() {
return itemPrice;
}
// method to get quantity of the item
public int getQuantity() {
return itemQuantity;
}
public String getDescription() {
return itemDescription;
}
public void printItemPurchase() {
System.out.println(itemName + " " +
itemQuantity + " @ $" + itemPrice + " = $" + (itemPrice *
itemQuantity));
}
public void printItemDescription() {
System.out.println(itemName+":
"+itemDescription);
}
}
*******************
shoppingcart.java
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class ShoppingCart {
private String customerName;
private String currentDate;
private List<ItemToPurchase> cartItems=new
ArrayList<>();
ShoppingCart() {
customerName = "none";
currentDate = "January 1,
2016";
}
ShoppingCart(String customerName, String currentDate)
{
super();
this.customerName =
customerName;
this.currentDate =
currentDate;
}
public String getCustomerName() {
return customerName;
}
public String getDate() {
return currentDate;
}
public void addItem(ItemToPurchase item) {
cartItems.add(item);
}
public void removeItem(String itemName) {
boolean check = false;
for (ItemToPurchase item :
cartItems) {
if(item.getName().equalsIgnoreCase(itemName)) {
cartItems.remove(item);
check=true;
}
}
if(!check)
System.out.println("Item not found in cart. Nothing
removed.");
}
public void modifyItem(ItemToPurchase item) {
boolean check = false;
for (ItemToPurchase itemToPurchase
: cartItems) {
if(itemToPurchase.getName().equalsIgnoreCase(item.getName()))
{
cartItems.remove(itemToPurchase);
cartItems.add(item);
check=true;
}
}
if(!check)
System.out.println("Item not found in cart. Nothing
modified.");
}
public int getNumItemsInCart() {
int total=0;
for (ItemToPurchase item :
cartItems) {
total+=item.getQuantity();
}
return total;
}
public int getCostOfCart() {
int cost=0;
for (ItemToPurchase item :
cartItems) {
cost+=item.getPrice()*item.getQuantity();
}
return cost;
}
public void printTotal() {
System.out.println(customerName+"'s
Shopping Cart - "+currentDate);
System.out.println("Number of
Items: "+getNumItemsInCart());
System.out.println();
for (ItemToPurchase item :
cartItems) {
System.out.println(item.getName()+" "+item.getQuantity()+" @
$"+item.getPrice()+" =
$"+(item.getQuantity()*item.getPrice()));
}
System.out.println();
System.out.println("Total:
$"+getCostOfCart());
}
public void printDesciptions() {
System.out.println(customerName+"'s
Shopping Cart - "+currentDate);
System.out.println();
System.out.println("Item
Descriptions");
for (ItemToPurchase item :
cartItems)
System.out.println(item.getName()+":
"+item.getDescription());
}
public static void main(String[] args) {
Scanner sc=new
Scanner(System.in);
System.out.println("Enter
Customer's Name:");
String name=sc.nextLine();
System.out.println("Enter Today's
Date:");
String date=sc.nextLine();
ShoppingCart cart=new
ShoppingCart(name,date);
System.out.println();
System.out.println();
}
}
ItemToPurchase.java
public class ItemToPurchase {
private String itemName;
private String itemDescription;
private int itemPrice;
private int itemQuantity;
public ItemToPurchase()
{
this.itemName = "none";
this.itemDescription = "none";
this.itemPrice = 0;
this.itemQuantity = 0;
}
public ItemToPurchase(String itemName, int itemPrice, int
itemQuantity, String itemDescription)
{
this.itemName = itemName;
this.itemDescription = itemDescription;
this.itemPrice = itemPrice;
this.itemQuantity = itemQuantity;
}
public void setName(String name) {
itemName = name;
}
public void setPrice(int price) {
itemPrice = price;
}
public void setQuantity(int quantity) {
itemQuantity = quantity;
}
public void setDescription(String description) {
itemDescription = description;
}
public String getName() {
return itemName;
}
public int getPrice() {
return itemPrice;
}
public int getQuantity() {
return itemQuantity;
}
public String getDescription() {
return itemDescription;
}
public void printItemPurchase() {
System.out.println(itemName + " " + itemQuantity + " @ $" +
itemPrice + " = $" + (itemPrice * itemQuantity));
}
public void printItemDescription() {
System.out.println(itemName + ": " + itemDescription);
}
}
ShoppingCart.java
import java.util.ArrayList;
import java.util.List;
public class ShoppingCart {
private String customerName;
private String currentDate;
private List<ItemToPurchase> cartItems = new
ArrayList<>();
ShoppingCart() {
customerName = "none";
currentDate = "January 1, 2016";
}
ShoppingCart(String customerName, String currentDate) {
super();
this.customerName = customerName;
this.currentDate = currentDate;
}
public String getCustomerName() {
return customerName;
}
public String getDate() {
return currentDate;
}
public void addItem(ItemToPurchase item) {
cartItems.add(item);
}
public List<ItemToPurchase> getCartItems() {
return cartItems;
}
public void removeItem(String itemName) {
boolean check = false;
for (ItemToPurchase item : cartItems) {
if (item.getName().equalsIgnoreCase(itemName)) {
cartItems.remove(item);
check = true;
break;
}
}
if (!check) {
System.out.println("Item not found in cart. Nothing
removed.");
}
}
public void modifyItem(ItemToPurchase item) {
boolean check = false;
for (ItemToPurchase itemToPurchase : cartItems) {
if (itemToPurchase.getName().equalsIgnoreCase(item.getName()))
{
cartItems.remove(itemToPurchase);
cartItems.add(item);
check = true;
break;
}
}
if (!check) {
System.out.println("Item not found in cart. Nothing
modified.");
}
}
public int getNumItemsInCart() {
int total = 0;
for (ItemToPurchase item : cartItems) {
total += item.getQuantity();
}
return total;
}
public int getCostOfCart() {
int cost = 0;
for (ItemToPurchase item : cartItems) {
cost += item.getPrice() * item.getQuantity();
}
return cost;
}
public void printTotal() {
System.out.println(customerName + "'s Shopping Cart - " +
currentDate);
System.out.println("Number of Items: " +
getNumItemsInCart());
System.out.println();
for (ItemToPurchase item : cartItems) {
System.out.println(item.getName() + " " + item.getQuantity() + " @
$" + item.getPrice() + " = $" + (item.getQuantity() *
item.getPrice()));
}
System.out.println();
System.out.println("Total: $" + getCostOfCart());
}
public void printDescriptions() {
System.out.println(customerName + "'s Shopping Cart - " +
currentDate);
System.out.println();
System.out.println("Item Descriptions");
for (ItemToPurchase item : cartItems) {
System.out.println(item.getName() + ": " +
item.getDescription());
}
}
}
ShoppingCartMain.java (Main class)
import java.util.Scanner;
public class ShoppingCartMain {
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
System.out.print("Enter Customer's Name: ");
String name = sc.nextLine();
System.out.print("Enter Today's Date: ");
String date = sc.nextLine();
ShoppingCart cart = new ShoppingCart(name,date);
System.out.println();
int choice;
do
{
displayMenu();
choice = Integer.parseInt(sc.nextLine().trim());
switch(choice)
{
case 1:
{
System.out.print("\nEnter item name: ");
String itemName = sc.nextLine().trim();
System.out.print("Enter item price: $");
int price = Integer.parseInt(sc.nextLine().trim());
System.out.print("Enter item quantity: ");
int quantity = Integer.parseInt(sc.nextLine().trim());
System.out.print("Enter item description: ");
String itemDesc = sc.nextLine().trim();
cart.addItem(new ItemToPurchase(itemName, price, quantity,
itemDesc));
break;
}
case 2:
{
System.out.print("\nEnter item name: ");
String itemName = sc.nextLine().trim();
System.out.print("Enter item price: $");
int price = Integer.parseInt(sc.nextLine().trim());
System.out.print("Enter item quantity: ");
int quantity = Integer.parseInt(sc.nextLine().trim());
System.out.print("Enter item description: ");
String itemDesc = sc.nextLine().trim();
cart.modifyItem(new ItemToPurchase(itemName, price, quantity,
itemDesc));
break;
}
case 3:
{
System.out.print("\nEnter item name: ");
String itemName = sc.nextLine().trim();
cart.removeItem(itemName);
break;
}
case 4:
{
System.out.println();
cart.printTotal();
break;
}
case 5:
{
System.out.println("\nThank you for shopping with
us!\nGoodbye!\n");
System.exit(0);
}
default:
System.out.println("\nInvalid choice!\n");
}
}while(choice != 5);
}
private static void displayMenu()
{
System.out.print("Choose from the following:\n"
+ "1. Add an item\n"
+ "2. Modify an item\n"
+ "3. Remove an item\n"
+ "4. Display all items\n"
+ "5. Exit\n"
+ "Your choice >> ");
}
}
******************************************************************* SCREENSHOT ********************************************************




I need a shoppingcartmanager.java that contains a main method for this code in java Itemtopurchase.java public...
CODES: main.cpp #include <iostream> #include <string> #include "ShoppingCart.h" using namespace std; char PrintMenu() { char answer; cout << "MENU" << endl; cout << "a - Add item to cart" << endl; cout << "d - Remove item from cart" << endl; cout << "c - Change item quantity" << endl; cout << "i - Output items' descriptions" << endl; cout << "o - Output shopping cart" << endl; cout << "q - Quit" << endl << endl; while (true) {...
Ch 7 Program: Online shopping cart (continued) (Java)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 fieldsstring itemDescription - Initialized in default constructor to "none"Parameterized constructor to assign item name, item description, item price, and item quantity (default values of 0). (1 pt)Public member methodssetDescription() mutator & getDescription() accessor (2 pts)printItemCost() - Outputs the item name followed by the quantity, price, and subtotalprintItemDescription() - Outputs the...
I need help with this assignment, can someone HELP ? This is the assignment: Online shopping cart (continued) (C++) This program extends the earlier "Online shopping cart" program. (Consider first saving your earlier program). (1) Extend the ItemToPurchase class per the following specifications: Parameterized constructor to assign item name, item description, item price, and item quantity (default values of 0). (1 pt) Public member functions SetDescription() mutator & GetDescription() accessor (2 pts) PrintItemCost() - Outputs the item name followed by...
Need three seperate files. ShoppingCartManager.java
ShoppingCart.java
ItemsToPurchase.java
These are from part 1
what do you mean by deep study
7.25 LAB*: Program: Online shopping cart (Part 2) Note: Creating multiple Scanner objects for the same input stream yields unexpected behavior. Thus, good practice is to use a single Scanner object for reading input from System.in. That Scanner object can be passed as an argument to any methods that read input This program extends the earlier Online shopping cart program (Consider...
Online shopping cart (continued) (Java) Hello, I need help with Java to figure this out. In my Shopping Cart Manager Class (Bottom Code), I get "Resource leak: 'sc' is never closed." I have tried multiple things and cannot figure it out. Thank you. Online shopping cart (continued) (Java) Hello, I need help with Java to figure this out. In my Shopping Cart Manager Class (Bottom Code), I get "Resource leak: 'sc' is never closed." I have tried multiple things and...
4.18 Ch 7 Program: Online shopping cart (continued) (C++) This program extends the earlier "Online shopping cart" program. (solution from previous lab assignment is provided in Canvas). (1) Extend the ItemToPurchase class per the following specifications: Parameterized constructor to assign item name, item description, item price, and item quantity (default values of 0). (1 pt) Public member functions SetDescription() mutator & GetDescription() accessor (2 pts) PrintItemCost() - Outputs the item name followed by the quantity, price, and subtotal PrintItemDescription() -...
Need help with the UML for this code? Thank you. import java.util.Scanner; public class Assignment1Duong1895 { public static void header() { System.out.println("\tWelcome to St. Joseph's College"); } public static void main(String[] args) { Scanner input = new Scanner(System.in); int d; header(); System.out.println("Enter number of items to process"); d = input.nextInt(); ...
8.7 LAB*: Program: Online shopping cart (Part 2)Note: Creating multiple Scanner objects for the same input stream yields unexpected behavior. Thus, good practice is to use a single Scanner object for reading input from System.in. That Scanner object can be passed as an argument to any methods that read input.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 fieldsstring itemDescription - Initialized in default constructor to "none"Parameterized...
I need help in converting this into pseudo-code Student.java public class Student implements Comparable<Student>{ private String name, major, status; private int rank; public Student() { this.name = this.major = this.status = ""; this.rank = 0; } public Student(String name, String major, String status) { this.name = name; this.major = major; this.status = status; } public String getName() { return name; } public String getMajor() { return major; } public String getStatus() { return status; } public int...
Thank you in advance. Create a class called Main and write the main method. I need help with calling the printChart method Declare a variable to hold the grade as it is read in Declare 5 variables to hold counts to count the number of As, Bs, Cs, etc declare a variable to hold the class name and ask the user to enter the name of the class whose grades are going to be entered. Write a loop that reads...