GH
GH
*;
import java.io.*;
import java.text.*;
public class fileread{
public static void main(String []args)throws IOException{
//>>Variables
String productID = "";
String data="";
String answer="";
String product[];
int check=0;
String str="",Discount="";
String strQuanTT="";
int QuanTT=0;
int counter=0;
double VAT=0, less=0;
double amount=0;
double Dproduct=0;
double PWD=0;
double PWD15=0;
double Senior=0, Suki=0,Senior20=0, Suki10=0;
double payment=0;
double amountDue=0;
double change=0;
System.out.println
("********************************************");
while(true){
System.out.print("Enter Product ID : ");
productID = scnr.next();
while((data = br.readLine())!=null){
product = data.split(", ");
if(productID.equals(product[0])){
System.out.println("Product name: " + product[1]);
System.out.println("Unit price: " + product[2]);
check = 1;
Dproduct = Double.parseDouble(product[2]);
}
}
if(check == 0){
System.out.println("Records Not Found!!!");}
check = 0;
fis.getChannel().position(0);
System.out.print
("Do yuo want to buy another Product? [ Yes/No ]: ");
answer = scnr.next();
if(answer.equalsIgnoreCase("No")){
System.out.println("The Program Will Terminate\n");
System.out.println
("********************************************");
System.out.println("Description");
System.out. println
("_________________________________________");
System.out.println("Prodoct"+"\t\t"+"Price"+"\t\t"+
"Quantity"+"\t"+"Total cost");
System.out.println(str);
System.out. println
("_________________________________________");
VAT = amount*0.12;
less = amount-VAT;
System.out.println("VAT: "+dcfm.format(VAT)
+"\t\t\t\t\t\t"+"["+dcfm.format(amount)+"]");
System.out.println("Less Vat: "+dcfm.format(less));
//--->> Discount
if (Discount.equalsIgnoreCase ("1")){
System.out.println
("Type of Discount: None ");}
else if (Discount.equalsIgnoreCase ("2")){
System.out.println
("Type of Discount: Senior Sitizen");}
else if (Discount.equalsIgnoreCase ("3")){
System.out.println
("Type of Discount: PWD");}
else {
System.out.println
("Type of Discoun:t Suki card: ");}
if (Discount.equalsIgnoreCase ("1")){
System.out.println
("Discount amount: ");}
else if (Discount.equalsIgnoreCase ("2")){
Senior = amount+VAT;
Senior20 = Senior*0.20;
System.out.println
("Discount amount: "+dcfm.format(Senior20));}
else if (Discount.equalsIgnoreCase ("3")){
PWD = amount+VAT;
PWD15 = PWD*0.15;
System.out.println
("Discount amount: "+dcfm.format(PWD15));}
else {
Suki = amount+VAT;
Suki10 = Suki*0.10;
System.out.println
("Discount amount: "+dcfm.format(Suki10));}
System.out.print("\n");
do {
System.out.print("Payment: Php ");
payment = scnr.nextDouble();
if (payment < amountDue){
System.out.println("your payment is insufficient 💸 🚫");}
} while(payment< amountDue);
{
{
change = (payment-amountDue);
if (Discount.equalsIgnoreCase ("1")){
System.out.print("Change: Php "+dcfm.format(change));}
else if (Discount.equalsIgnoreCase ("2")){
System.out.print("Change: Php "+dcfm.format(change));}
else if (Discount.equalsIgnoreCase ("3")){
System.out.print("Change: Php "+dcfm.format(change));}
else {
System.out.print("Change: Php "+dcfm.format(change));}
System.exit(0);
}
}
}
}
}
}