please send me answer within 10 min!! i will rate you good for sure!! Please provide explaination!!   I need help i have my java code all written out but it wont print anything after the second price? it just keeps giving me an exception of main InputMismatchException?   ////////. 1/2 files import java.util.Scanner; public class ShoppingCartPrinter { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); /* Type your code here. */ String name; int price = 0; int quantity = 0;    ItemToPurchase item1 = new ItemToPurchase(); ItemToPurchase item2 = new ItemToPurchase();    System.out.println("Item 1");    System.out.println("Enter the item name:"); name = scnr.nextLine(); item1.setName(name);    System.out.println("Enter the item price:"); price = scnr.nextInt(); item1.setPrice(price);    System.out.println("Enter the item quantity:"); quantity = scnr.nextInt(); item1.setQuantity(quantity);    //System.out.println();    System.out.println("\nItem 2");    System.out.println("Enter the item name:"); name = scnr.nextLine(); item2.setName(name);    System.out.println("Enter the item price:"); price = scnr.nextInt(); item2.setPrice(price);    System.out.println("Enter the item quantity:"); quantity = scnr.nextInt(); item2.setQuantity(quantity);    //System.out.println();       System.out.println("\nTOTAL COST"); System.out.println(item1.getName() + " " + item1.getQuantity() + " @ $" + item1.getPrice() + " = $" + (item1.getPrice() * item1.getQuantity())); System.out.println(item2.getName() + " " + item2.getQuantity() + " @ $" + item2.getPrice() + " = $" + (item2.getPrice() * item2.getQuantity()));    System.out.println("\nTotal: " + ((item1.getPrice() * item1.getQuantity()) + (item2.getPrice() * item2.getQuantity())));    }//end of main }//end of class ShoppingCartPrinter   ////. 2/2 file public class ItemToPurchase{    private String itemName; private int itemPrice; private int itemQuantity; public ItemToPurchase(){ }//end of ItemToPurchase public String getName(){ return itemName;    }//end getName public void setName(String itemName){ this.itemName = itemName;    }//end itemName public int getPrice(){ return itemPrice;    }//end getPrice public void setPrice(int itemPrice){ this.itemPrice = itemPrice;    }//end setPrice public int getQuantity(){ return itemQuantity;    }//end getQuatity public void setQuantity(int itemQuantity){ this.itemQuantity = itemQuantity;    }//end setQuantity }//end class ItemToPurchase

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

please send me answer within 10 min!! i will rate you good for sure!! Please provide explaination!!

 

I need help i have my java code all written out but it wont print anything after the second price? it just keeps giving me an exception of main InputMismatchException?

 

////////. 1/2 files

import java.util.Scanner;

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

/* Type your code here. */
String name;
int price = 0;
int quantity = 0;
  
ItemToPurchase item1 = new ItemToPurchase();
ItemToPurchase item2 = new ItemToPurchase();
  
System.out.println("Item 1");
  
System.out.println("Enter the item name:");
name = scnr.nextLine();
item1.setName(name);
  
System.out.println("Enter the item price:");
price = scnr.nextInt();
item1.setPrice(price);
  
System.out.println("Enter the item quantity:");
quantity = scnr.nextInt();
item1.setQuantity(quantity);
  
//System.out.println();
  
System.out.println("\nItem 2");
  
System.out.println("Enter the item name:");
name = scnr.nextLine();
item2.setName(name);
  
System.out.println("Enter the item price:");
price = scnr.nextInt();
item2.setPrice(price);
  
System.out.println("Enter the item quantity:");
quantity = scnr.nextInt();
item2.setQuantity(quantity);
  
//System.out.println();
  
  
System.out.println("\nTOTAL COST");
System.out.println(item1.getName() + " " + item1.getQuantity() + " @ $" + item1.getPrice() + " = $" + (item1.getPrice() * item1.getQuantity()));
System.out.println(item2.getName() + " " + item2.getQuantity() + " @ $" + item2.getPrice() + " = $" + (item2.getPrice() * item2.getQuantity()));
  
System.out.println("\nTotal: " + ((item1.getPrice() * item1.getQuantity()) + (item2.getPrice() * item2.getQuantity())));
  
}//end of main
}//end of class ShoppingCartPrinter

 

////. 2/2 file

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

public ItemToPurchase(){

}//end of ItemToPurchase

public String getName(){
return itemName;   
}//end getName

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

public int getPrice(){
return itemPrice;   
}//end getPrice

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

public int getQuantity(){
return itemQuantity;   
}//end getQuatity

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

}//end class ItemToPurchase

Expert Solution
steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
Constants and Variables
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education