Can you help me fix my code because the total sum per item does not show in the receipt and when choosing to perform another transaction, the input for the customer's name and the number of items overlaps as seen in the image below.   package cashier; import java.util.Scanner; class List { Scanner sc = new Scanner(System.in); private String name; private int item; private int[] des; private double price; private int[] quan; private double total; private double sum; public List(String name, int item, int[] des, double total, int[] quan, double sum) { this.name = name; this.item = item; this.des = des; this.quan = quan; this.total = total; this.sum = sum; } public void Input() { System.out.print("\n Enter name of customer: "); name = sc.nextLine(); System.out.print(" Enter number of items: "); item = sc.nextInt(); des = new int[item]; quan = new int[item]; total = 0; for (int i = 0; i < item; i++) { System.out.print("\n Enter item code: "); des[i] = sc.nextInt(); for (int j = 0; j < item; j++) { if (des[j]==1001) { price = 120.00; System.out.println(" 1001 Item name: Crayons Php 120.00\n"); } else if (des[j]==1002) { price = 17.25; System.out.println(" 1002 Item name: Eraser Php 17.25\n"); } else if (des[j]==1003) { System.out.println(" 1003 Item name: Folder Php 12.75"); } else if (des[j]==1004) { System.out.println(" 1004 Item name: Glue Php 59.75"); } else if (des[j]==1005) { System.out.println(" 1005 Item name: Highlighter Php 36.75"); } else if (des[j]==1006) { System.out.println(" 1006 Item name: Notebook Php 44.75"); } else if (des[j]==1007) { System.out.println(" 1007 Item name: Paper Php 50.00"); } else if (des[j]==1008) { System.out.println(" 1008 Item name: Pen Php 23.50"); } else if (des[j]==1009) { System.out.println(" 1009 Item name: Pencil Php 12.00"); } else if (des[j]==1010) { System.out.println(" 1010 Item name: Ruler Php 16.00"); } else if (des[j]==1011) { System.out.println(" 1011 Item name: Scissors Php 79.75"); } sum = price *quan[i]; } System.out.print(" Enter quantity: "); quan[i] = sc.nextInt(); total+=price*quan[i]; } } public void Receipt() { System.out.println("\n\n **********************************"); System.out.println("\t\tRECEIPT"); System.out.println(" **********************************"); System.out.println("\t We'll always be your"); System.out.println("\t Favorite Store"); System.out.println(); System.out.print(" S.No "); System.out.print("Item name "); System.out.print(" Quantity "); System.out.print(" Price "); System.out.println(); for (int i = 0; i < item; i++) { if (des[i]==1001) { System.out.println(" 1001 Crayons "+quan[i]+" "+sum); System.out.println(" 120.00"); } else if (des[i]==1002) { System.out.println(" 1002 Eraser "+quan[i]+" "+sum); System.out.println(" 17.25"); } else if (des[i]==1003) { System.out.println(" 1003 Folder "+quan[i]+" "+sum); System.out.println(" 12.75"); } else if (des[i]==1004) { System.out.println(" 1004 Glue "+quan[i]+" "+sum); System.out.println(" 59.75"); } else if (des[i]==1005) { System.out.println(" 1005 Highlighter "+quan[i]+" "+sum); System.out.println(" 36.75"); } else if (des[i]==1006) { System.out.println(" 1006 Notebook "+quan[i]+" "+sum); System.out.println(" 44.75"); } else if (des[i]==1007) { System.out.println(" 1007 Paper "+quan[i]+" "+sum); System.out.println(" 50.00"); } else if (des[i]==1008) { System.out.println(" 1008 Pen "+quan[i]+" "+sum); System.out.println(" 23.50"); } else if (des[i]==1009) { System.out.println(" 1009 Pencil "+quan[i]+" "+sum); System.out.println(" 12.00"); } else if (des[i]==1010) { System.out.println(" 1010 Ruler "+quan[i]+" "+sum); System.out.println(" 16.00"); } else if (des[i]==1011) { System.out.println(" 1011 Scissors "+quan[i]+" "+sum); System.out.println(" 79.75"); } } System.out.println(); System.out.println("\n\tSubtotal: " + this.total); double vat = (float) 0.12 * this.total; System.out.println(" \t12% VAT: "+ vat); double gtotal = (float) this.total + vat; System.out.println(" \n\tAmount Due: " + gtotal); System.out.print(" \tCash: "); float cash = (float) sc.nextDouble(); double change = cash - gtotal; System.out.println(" \tChange: " + change); int qty = 0 ; System.out.println("\n\t 12% VAT included"); for (int i = 0; i

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

Can you help me fix my code because the total sum per item does not show in the receipt and when choosing to perform another transaction, the input for the customer's name and the number of items overlaps as seen in the image below.

 

package cashier;

import java.util.Scanner;

class List {

Scanner sc = new Scanner(System.in);

private String name;
private int item;
private int[] des;
private double price;
private int[] quan;
private double total;
private double sum;

public List(String name, int item, int[] des, double total, int[] quan, double sum) {
this.name = name;
this.item = item;
this.des = des;
this.quan = quan;
this.total = total;
this.sum = sum;
}

public void Input() {

System.out.print("\n Enter name of customer: ");
name = sc.nextLine();
System.out.print(" Enter number of items: ");
item = sc.nextInt();
des = new int[item];
quan = new int[item];
total = 0;

for (int i = 0; i < item; i++) {
System.out.print("\n Enter item code: ");
des[i] = sc.nextInt();
for (int j = 0; j < item; j++) {
if (des[j]==1001) {
price = 120.00;
System.out.println(" 1001 Item name: Crayons Php 120.00\n");
}
else if (des[j]==1002) {
price = 17.25;
System.out.println(" 1002 Item name: Eraser Php 17.25\n");
}
else if (des[j]==1003) {

System.out.println(" 1003 Item name: Folder Php 12.75");
}
else if (des[j]==1004) {
System.out.println(" 1004 Item name: Glue Php 59.75");
}
else if (des[j]==1005) {
System.out.println(" 1005 Item name: Highlighter Php 36.75");
}
else if (des[j]==1006) {
System.out.println(" 1006 Item name: Notebook Php 44.75");
}
else if (des[j]==1007) {
System.out.println(" 1007 Item name: Paper Php 50.00");
}
else if (des[j]==1008) {
System.out.println(" 1008 Item name: Pen Php 23.50");
}
else if (des[j]==1009) {
System.out.println(" 1009 Item name: Pencil Php 12.00");
}
else if (des[j]==1010) {
System.out.println(" 1010 Item name: Ruler Php 16.00");
}
else if (des[j]==1011) {
System.out.println(" 1011 Item name: Scissors Php 79.75");
}
sum = price *quan[i];
}
System.out.print(" Enter quantity: ");
quan[i] = sc.nextInt();
total+=price*quan[i];
}
}

public void Receipt() {
System.out.println("\n\n **********************************");
System.out.println("\t\tRECEIPT");
System.out.println(" **********************************");
System.out.println("\t We'll always be your");
System.out.println("\t Favorite Store");
System.out.println();
System.out.print(" S.No ");
System.out.print("Item name ");
System.out.print(" Quantity ");
System.out.print(" Price ");
System.out.println();

for (int i = 0; i < item; i++) {
if (des[i]==1001) {
System.out.println(" 1001 Crayons "+quan[i]+" "+sum);
System.out.println(" 120.00");
}
else if (des[i]==1002) {
System.out.println(" 1002 Eraser "+quan[i]+" "+sum);
System.out.println(" 17.25");
}
else if (des[i]==1003) {
System.out.println(" 1003 Folder "+quan[i]+" "+sum);
System.out.println(" 12.75");
}
else if (des[i]==1004) {
System.out.println(" 1004 Glue "+quan[i]+" "+sum);
System.out.println(" 59.75");
}
else if (des[i]==1005) {
System.out.println(" 1005 Highlighter "+quan[i]+" "+sum);
System.out.println(" 36.75");
}
else if (des[i]==1006) {
System.out.println(" 1006 Notebook "+quan[i]+" "+sum);
System.out.println(" 44.75");
}
else if (des[i]==1007) {
System.out.println(" 1007 Paper "+quan[i]+" "+sum);
System.out.println(" 50.00");
}
else if (des[i]==1008) {
System.out.println(" 1008 Pen "+quan[i]+" "+sum);
System.out.println(" 23.50");
}
else if (des[i]==1009) {
System.out.println(" 1009 Pencil "+quan[i]+" "+sum);
System.out.println(" 12.00");
}
else if (des[i]==1010) {
System.out.println(" 1010 Ruler "+quan[i]+" "+sum);
System.out.println(" 16.00");
}
else if (des[i]==1011) {
System.out.println(" 1011 Scissors "+quan[i]+" "+sum);
System.out.println(" 79.75");
}

}
System.out.println();

System.out.println("\n\tSubtotal: " + this.total);
double vat = (float) 0.12 * this.total;
System.out.println(" \t12% VAT: "+ vat);
double gtotal = (float) this.total + vat;
System.out.println(" \n\tAmount Due: " + gtotal);
System.out.print(" \tCash: ");
float cash = (float) sc.nextDouble();
double change = cash - gtotal;
System.out.println(" \tChange: " + change);

int qty = 0 ;
System.out.println("\n\t 12% VAT included");
for (int i = 0; i<item; i++) {
qty = qty + quan[i];
}

}

}

public class Cashier {

public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int reply, total = 0;
int[] quan = null;
String name = "";
int[] des = null;
double sum = 0;
List obj = new List(name, total, des, total, quan, sum);

do {
System.out.println(" \n\tWelcome to Favorite Store"
+ "\n\t Philippines\n"
+ "\n VAT Reg TIN: 123-456-789-000");


obj.Input();
obj.Receipt();
System.out.println("\nPerform another transaction? yes (1) / no (2)");
reply = sc.nextInt();

if (reply == 2) {
System.out.println("\n\tThank you for using the system!");
}
} while (reply == 1);
sc.close();

}

}

T00I Item Tiame . CrayoS
Pip 1z0.00
Enter quantity: 1
Enter item code: 1002
1001 Item name: Crayons
Php 120.00
1002 Item name: Eraser
Php 17.25
Enter quantity: 3
RECEIPT
We'll always be your
Favorite Store
S.No Item name
Quantity
Price
1001 Crayons
1
0.0
120.00
1002 Eraser
3
0.0
17.25
Subtotal:
171.75
12% VAT:
20.6099995393306
Amount Due: 192.3599995393306
Cash:
200
Change:
7.640000460669398
12% VAT included
Perform another transaction? yes (1) / no (2)
Welcome to Favorite Store
Philippines
VAT Reg TIN: 123-456-789-000
Enter name of customer: Enter number of items:
Transcribed Image Text:T00I Item Tiame . CrayoS Pip 1z0.00 Enter quantity: 1 Enter item code: 1002 1001 Item name: Crayons Php 120.00 1002 Item name: Eraser Php 17.25 Enter quantity: 3 RECEIPT We'll always be your Favorite Store S.No Item name Quantity Price 1001 Crayons 1 0.0 120.00 1002 Eraser 3 0.0 17.25 Subtotal: 171.75 12% VAT: 20.6099995393306 Amount Due: 192.3599995393306 Cash: 200 Change: 7.640000460669398 12% VAT included Perform another transaction? yes (1) / no (2) Welcome to Favorite Store Philippines VAT Reg TIN: 123-456-789-000 Enter name of customer: Enter number of items:
Welcome to Favorite Store
Philippines
VAT Reg TIN: 123-456-789-000
Enter name of customer: abc
Enter number of items: 2
Enter item code: 1001
1001 Item name: Crayons
Php 120.00
Enter quantity: 1
Enter item code: 1002
1001 Item name: Crayons
Php 120.00
1002 Item name: Eraser
Php 17.25
Enter quantity: 3
RECEIPT
We'll always be your
Favorite Store
S.No Item name
Quantity
Price
1001 Crayons
1
0.0
120.00
1002 Eraser
3
0.0
17.25
Subtotal:
171.75
12% VAT:
20.6099995393306
Amount Due:
192.3599995393306
Cash:
200
Change:
7.640000460669398
Transcribed Image Text:Welcome to Favorite Store Philippines VAT Reg TIN: 123-456-789-000 Enter name of customer: abc Enter number of items: 2 Enter item code: 1001 1001 Item name: Crayons Php 120.00 Enter quantity: 1 Enter item code: 1002 1001 Item name: Crayons Php 120.00 1002 Item name: Eraser Php 17.25 Enter quantity: 3 RECEIPT We'll always be your Favorite Store S.No Item name Quantity Price 1001 Crayons 1 0.0 120.00 1002 Eraser 3 0.0 17.25 Subtotal: 171.75 12% VAT: 20.6099995393306 Amount Due: 192.3599995393306 Cash: 200 Change: 7.640000460669398
Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Similar 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