import java.util.*;
import java.io.*;
public class Assignment2
{
public static void main(String[]args ) throws FileNotFoundException
{
String[] A= {"Aaron Technology Sdn Bhd", "Bagunan Aziz dan Anak-anak"//0 1
, "Blok'A', Tingkat 1, No.4","Jalan Adam, Simpang 234",// 2 3
"AST-Beyond, Kuala Hawa", "Brunie CH134", "Receipt No",// 4 5 6
"Customer Name :", "Payment Term :", "Item No. : ",// 7 8 9
"-----------------------------"," ","Total Include GST of 5% :", //10 11 12
"Total Amount", // 13
"------------------------------------Cut Here ---------------------------------", // 14
"Discount Rate : 10%"}; //15
String PaymentTerm , PaymentTerm2, CustomerName, ItemNo , ItemName , CREDIT, CASH ;
double x=0.00,Quantity,Price = 1 , Tax =0.05 , ReceiptNo ;
Scanner readFile = new Scanner(new FileReader("C:\\Users\\user\\Documents\\DIT MKJB\\Programming Java\\customer.txt"));
PrintWriter writeFile = new PrintWriter("C:\\Users\\user\\Desktop\\receipts.txt");
while(readFile.hasNext())
{
//Categories being read in Customer.txt file
ReceiptNo = readFile.nextDouble();
PaymentTerm = readFile.next();
CustomerName = readFile.next();
ItemNo = readFile.next();
ItemName = readFile.next();
Quantity = readFile.nextDouble();
Price = readFile.nextDouble();
writeFile.printf("%53s %n%54s %n%53s %n%52s %n%52s %n%46s%n",A[0],A[1],A[2],A[3],A[4],A[5]);
if( PaymentTerm == CREDIT )
{
writeFile.println(); // RECEIPT NO
writeFile.printf("%43s %s %n%55s %n%41s %s %n%40s %s %n%37s %n%37s %s %n%55s %n"// Discount Displayed
,A[6],ReceiptNo,A[10],A[7],CustomerName,A[8],PaymentTerm,A[15],A[9],ItemNo,A[10]);
x = Quantity * Price;
writeFile.printf("%26s%.0f x %.2f %10s $%.2f %n%55s %n%38s "
,A[11],Quantity,Price,A[11],x,A[10],A[13]);
x = x + (x * Tax);
writeFile.printf("%n%51s $%.2f %n%n%s",A[12],x,A[14]);
writeFile.println();
}
if ( PaymentTerm == CASH )
{ writeFile.println(); // RECEIPT NO
writeFile.printf("%43s %s %n%55s %n%41s %s %n%40s %s %n%37s %s %n%55s %n"// Do not have discount displayed
,A[6],ReceiptNo,A[10],A[7],CustomerName,A[8],PaymentTerm,A[9],ItemNo,A[10]);
x = Quantity * Price;
writeFile.printf("%26s%.0f x %.2f %10s $%.2f %n%55s %n%38s "
,A[11],Quantity,Price,A[11],x,A[10],A[13]);
x = x + (x * Tax);
writeFile.printf("%n%51s $%.2f %n%n%s",A[12],x,A[14]);
writeFile.println();
}
}