John Delmark Aguilar
Would you like to react to this message? Create an account in a few clicks or log in to continue.
John Delmark Aguilar

Personal Forum
 
HomeSearchLatest imagesRegisterLog in

 

 InputStream

Go down 
AuthorMessage
dElmARk
Admin
Admin
dElmARk


Posts : 92
Join date : 09/04/2012

InputStream Empty
PostSubject: InputStream   InputStream Icon_minitimeSat Feb 23, 2013 11:24 pm

Code:
import java.io.*;
import java.util.*;
public class FastFood
{
   public static void main(String[]ecs)throws IOException
   {
   Scanner sc = new Scanner(System.in);
   FileWriter fw = new FileWriter("Receipt.txt",true);
   System.out.print("Enter Item Code: ");
   String code = sc.nextLine();
   fw.write("Item Code: " + code);

   FileInputStream fis = new FileInputStream("Menulist.txt");
   DataInputStream dis = new DataInputStream(fis);
   BufferedReader bf = new BufferedReader(new InputStreamReader(dis));
   
   String itemcode="";
   String element[];
      while((itemcode=bf.readLine())!=null)
      {
      element = itemcode.split(" , ");
         if(code.equals(element[0]))
         {
         System.out.println("Description: "+element[1]);
         fw.write("\r\nDescription: "+element[1]);
         System.out.println("Type: "+element[2]);
         fw.write("\r\nType: "+element[2]);
         System.out.println("Cost: "+element[3]);
         fw.write("\r\nCost: "+element[3]);
         System.out.print("Enter Quantity: ");
         double qty = sc.nextDouble();
         fw.write("\r\nQuantity: "+qty);
         double totalcost = Double.parseDouble(element[3])*qty;
         System.out.println("Total Cost: "+totalcost);
         fw.write("\r\nTotal Cost: "+totalcost);
         System.out.print("Enter Payment: ");
         double cash = sc.nextDouble();
         fw.write("\r\nCash Paid: "+cash);
         double vat = totalcost*0.12;
         double lessvat = totalcost-vat;
         double change = cash-totalcost;
         System.out.println("Change: "+change);
         fw.write("\r\nChange: "+change);
         System.out.println("12% vat: "+vat);
         fw.write("\r\n12% VAT: "+vat);
         System.out.println("Less VAT: "+lessvat);
         fw.write("\r\nLess VAT: "+lessvat);
         fw.write("\r\n*****THANK YOU!!*****\r\n\r\n");
         fw.close();
         }
      }
   }
}
Back to top Go down
https://delmark.forumtl.com
dElmARk
Admin
Admin
dElmARk


Posts : 92
Join date : 09/04/2012

InputStream Empty
PostSubject: Re: InputStream   InputStream Icon_minitimeSat Feb 23, 2013 11:25 pm

Menulist.txt

Code:
001 , Spaghetti , Pasta , 75
002 , Pancit , Noodles , 100
003 , Coke , Drinks , 30
Back to top Go down
https://delmark.forumtl.com
 
InputStream
Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
John Delmark Aguilar :: dElmARk Productions :: Java Programs :: Tutorials-
Jump to: