import java.util.*;
import java.io.*;
import java.util.Arrays;
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
String PaymentTerm, CustomerName, ItemNo , ItemName ;
double x=0.00,Quantity,Price = 1 , Tax =0.05 , CREDIT =0.1 , 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())
{
ReceiptNo = readFile.nextDouble();
PaymentTerm = readFile.next();
CustomerName = readFile.next();
ItemNo = readFile.next();
ItemName = readFile.next();
Quantity = readFile.nextDouble();
Price = readFile.nextDouble();
CREDIT = 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]);
writeFile.println(); // RECEIPT NO 001
writeFile.printf("%43s %s \n%55s \n%41s Ahmad \n%40s CASH \n%37s PD80512 \n%55s \n"
,A[6],ReceiptNo,A[10],A[7],A[8],A[9],A[10]);
x = Quantity * Price;
x = 2 * 65.00;
writeFile.printf("%26s2 x 65.00 %10s $%.2f \n%55s \n%38s "
,A[11],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();
}
System.out.println(" Your File receipts.txt has been successfully created");
readFile.close();
writeFile.close();
}
}