Thanks I have manage to do something the application is running now but how can I used thread to turn it in a muilti-user system?
here is the code so far
import java.util.*;
public class PointOfSales{
public static void main(String [] args){
System.out.println("\\f");
Scanner input = new Scanner(System.in);
System.out.println(" XTREME POS SYSTEM \
");
do{
System.out.println("Enter product code [0 - 9] and qauntity [0 - 9] then press 0 to calculate and print receipt");
while(true){
System.out.print("\
Product code = ");
String code = input.next();
System.out.print("Quantity = ");
int qty = input.nextInt();
if((code == SENTINEL) || (qty == 0)){
break;
}
double pr = getPrice(code);
String ds = getDesc(code, qty);
double check = pr * qty;
total += check;
output += ds;
}
System.out.println("\
");
System.out.println(output);
System.out.println("Total is: " + total);
System.out.println(“Do you wish to continue? (yes or no)”);
condition = input.next();
}while(condition.equals("yes"));
}
private static double getPrice(String thecode){
String code = thecode;
if(code.equals("0011")){
price = 176.2;
}
else if(code.equals("0012")){
price = 156.7;
}
else if(code.equals("0013")){
price = 186.2;
}
else if(code.equals("0014")){
price = 256.3;
}
else if(code.equals("0015")){
price = 216.8;
}
return price;
}
private static String getDesc(String desc, int q){
String description = desc;
int quantity = q;
if(description.equals("0011")){
descs = "Product Code -: 0011 \
Quantity -: " + quantity + "
Price -: $176.2
";
}
else if(description.equals("0012")){
descs = "Product Code -: 0012 \
Quantity -: " + quantity + "
Price -: $156.7
";
}
else if(description.equals("0013")){
descs = "Product Code -: 0013 \
Quantity -: " + quantity + "
Price -: $186.2
";
}
else if(description.equals("0014")){
descs = "Product Code -: 0014 \
Quantity -: " + quantity + "
Price -: $256.3
";
}
else if(description.equals("0015")){
descs = "Product Code -: 0015 \
Quantity -: " + quantity + "
Price -: $216.8
";
}
return descs;
}
static final String SENTINEL = "0";
static String condition = "no";
static String descs;
static String output = "==+++++++++++++++++++++++++++++++++++++++++++++++++++++==\
Product Detials
==+++++++++++++++++++++++++++++++++++++++++++++++++++++==
";
static double total;
static int cal;
static double price;
}