Can someone help me fix my code? I need to make a cashiering system with a receipt. I also wanted to include the time and date in the receipt
Can someone help me fix my code? I need to make a cashiering system with a receipt. I also wanted to include the time and date in the receipt
import java.util.Scanner;
class List{
private String name;
private int item;
private String[] des;
private int[] price;
private int[] quan;
private int total;
public List (String name, int item, String[] des, int total, int[] price) {
this.name = name;
this.item = item;
this.des = des;
this.price = price;
this.total = total;
}
public void Input() {
Scanner sc=new Scanner(System.in);
System.out.print("Enter name of customer:");
name=sc.next();
System.out.print("Enter the Number of items:");
item=sc.nextInt();
String []des=new String[item];
int []price=new int[item];
int []quan = new int [item];
total=0;
for (int i=0; i<item; i++) {
System.out.print("Enter item name:");
des[i]=sc.next();
System.out.print("Enter price:");
price[i]=sc.nextInt();
System.out.print("Enter quantity:");
quan [i]=sc.nextInt();
sc.close();
}
}
public void Menu() {
System.out.print("Item list:\n");
System.out.println("Scisscors\n"
+ "Ruler\n"
+ "Crayons\n"
+ "Glue\n"
+ "Eraser\n"
+ "Notebook\n"
+ "Paper\n"
+ "Highlighter\n"
+ "Folder\n"
+ "Pen\n"
+ "Pencil\n");
}
public int Total(int x) {
return x;
}
public void Receipt() {
System.out.println("From");
System.out.println("XYZ MARket Place");
System.out.println("Customer Name: "+ this.name);
System.out.println();
System.out.print("S.No ");
System.out.print("Item name ");
System.out.print("Price ");
System.out.println();
for(int i=0;i<item;i++){
System.out.print(" "+i+ " ");
System.out.print(des[i]+" ");
System.out.print(price[i]);
System.out.println();
}
System.out.println(" Subtotal: "+this.total);
System.out.println(" VAT: 12%");
float vat=(float)0.12*this.total;
float gtotal=(float)this.total+vat;
System.out.println(" total:"+gtotal);
}
}
public class Pajanconi {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int reply, total = 0, price[], quan[] = null;
String name= "";
List obj = new List(name, total, args, total, quan);
obj.Menu();
do {
obj.Input();
obj.Receipt();
System.out.println("Perform another transaction? yes (1) / no (2)");
reply = sc.nextInt();
}while (reply == 1 );
sc.close();
}
}
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images