//AUTHOR OF THE PROJECT: Mrunal.N.C
import java.io.*; //Importing java.io packageimport java.util.*; //Importing java.util package import java.net.*; //Importing java.net packageimport java.awt.*; //Importing java.awt packageimport java.nio.*; //Importing java.nio packageimport java.math.*; //Importing java.math package
public class Bill
{
String item[]={" Full Meals "," Dum Aloo "," Dosa "," Naan "," Palak Paneer "," Dal "," Mini Meals "," Samosa "," Fried Rice ","Chana Masala "}; //Variable to store food items double rate[]={200,75,35,45,75,55,155,20,40,65}; //Variable to store cost of food items String order[]=new String[10]; //Creating an Array of Base Type String and of length 10 double amt[]=new double[10]; //Creating an Array of Base Type double and of length 10 String ans; // Variable to store answer that is, any more items are required by the user or not char ch; // Variable to store the answer whether the applicarion has to be continued or not int plates[]=new int[10]; //Creating an Array of Base Type int and of length 10 int i,n=0,no,x=0; static Bill object =new Bill(); //Creating an object of Bill type
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
Bill() //A default Constructor { }
public void putOrder()throws Exception //A function putOrder returning no value(void return type)with a public access specifier { System.out.println(" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); System.out.println(" Four Seasons Hotel "); System.out.println(" Menu Card "); //Displaying the MENU System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); System.out.println(" Item No. Item Rate/plate"); for(i=0;i< 10;i++){ System.out.println(" "+(i+1)+ ": "+item[i]+" "+rate[i]); }
for(int i=1;i<=1;i++){
System.out.println(" \n Enter item number from 1 to 10 to place order\n");
}x=0; while(true){if(x==10)break;
Scanner sc=new Scanner(System.in); System.out.print(" Please enter the item number :"); no=sc.nextInt(); order[x]=item[no-1]; amt[x]=rate[no-1]; System.out.print(" Please Enter the number of plates :"); no=Integer.parseInt(br.readLine()); plates[x]=no; x++; if(x>0) { System.out.print(" Any More Item ?(Y/N):"); ans=br.readLine().toUpperCase(); if(ans.equals("N")) break; } } showBill(); } //putOrder function ends here private void showBill() throws Exception{
double bamt=0,b;
System.out.println("\f");System.out.println(" You have ordered\n");System.out.println(" Item Rate No. of Plates");
for(i=0;i< x;i++) { System.out.println(" "+(i+1)+":"+order[i]+" "+amt[i]+" "+plates[i]); } while(true) { if(x< 2) break; System.out.print(" Want to cancel any item (Y/N):"); ans=br.readLine().toUpperCase(); if(ans.equals("N")) break; //If the user wants to cancell any item System.out.print(" Which item to cancel, enter item number:"); no=Integer.parseInt(br.readLine()); for(i=no-1;i< x-1;i++) { order[i]=order[i+1]; amt[i]=amt[i+1]; plates[i]=plates[i+1]; } x--; } //Displaying Bill System.out.println("\f"); System.out.println(" Cash Memo\n"); System.out.println(" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); System.out.println(" Four Seasons Hotel "); System.out.println(" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); System.out.println(" Item No. of plates Rate Amount"); System.out.println(" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); for (i=0;i< x;i++) { System.out.print(" "+order[i]+ " "+plates[i]+ " "+ amt[i]+ " "); b=plates[i]*amt[i]; System.out.println(b); bamt=bamt+b; } System.out.println(" Bill Amount Rs. "+bamt); System.out.println(" ____________________________________________________________________________________"); bamt=bamt+bamt*.125; System.out.println(" Total Amount including service charge @ 12.5% Rs. "+bamt); System.out.println(" ____________________________________________________________________________________"); System.out.println(" THANK YOU VISIT AGAIN"); System.out.println(" Press any key to continue :"); String ab=br.readLine(); }
public static void main(String[]args)throws Exception{ //Handling Exceptionsdo{
try{ object.n=0; object.i=0; object.no=0; object.ans=""; for(int y=0;y<10;y++) { object.order[y]=""; object.amt[y]=0; object.plates[y]=0; } object.putOrder(); //Calling the function putOrder System.out.print("\f"); //Clearing the Screne } catch(ArithmeticException e1) { System.out.println("Sorry some problem has occured"); } catch(ArrayIndexOutOfBoundsException e2) { System.out.println(" Sorry we dont have such item");
} catch(NumberFormatException e3) { System.out.println(" The input was not a number therfore an error has occured "); } catch(ArrayStoreException e4) { System.out.println(" Sorry some problem has occured" ); } catch(ClassCastException e5) { System.out.println(" An error has occured please run the application again"); } catch(IllegalArgumentException e6) { System.out.println(" An error has occured please run the application again"); } catch(IllegalStateException e7) { System.out.println(" An error has occured please run the application again"); } catch(IndexOutOfBoundsException e9) { System.out.println(" An error has occured please run the application again"); } catch(NegativeArraySizeException e10) { System.out.println(" An error has occured please run the application again"); } catch(NullPointerException e11) { System.out.println(" An error has occured please run the application again"); } catch(SecurityException e12) { System.out.println(" An error has occured please run the application again"); } catch(UnsupportedOperationException e13) { System.out.println(" An error has occured please run the application again"); } catch(java.util.InputMismatchException e14) { System.out.println(" The Input was wrong therfore an error has occured "); } System.out.print("\n Do you want to continue the Application(Y/N)? :"); object.ch=(char)System.in.read(); //If ch is N or n the Applications ends object.ch=Character.toUpperCase(object.ch); System.out.print("\f"); }while(object.ch!='N'); //Loop get excuited as long as ch is not equal to n or N
System.out.println("\f\n T H A N K Y O U ! !"); }}// Program Ends
import java.io.*; //Importing java.io packageimport java.util.*; //Importing java.util package import java.net.*; //Importing java.net packageimport java.awt.*; //Importing java.awt packageimport java.nio.*; //Importing java.nio packageimport java.math.*; //Importing java.math package
public class Bill
{
String item[]={" Full Meals "," Dum Aloo "," Dosa "," Naan "," Palak Paneer "," Dal "," Mini Meals "," Samosa "," Fried Rice ","Chana Masala "}; //Variable to store food items double rate[]={200,75,35,45,75,55,155,20,40,65}; //Variable to store cost of food items String order[]=new String[10]; //Creating an Array of Base Type String and of length 10 double amt[]=new double[10]; //Creating an Array of Base Type double and of length 10 String ans; // Variable to store answer that is, any more items are required by the user or not char ch; // Variable to store the answer whether the applicarion has to be continued or not int plates[]=new int[10]; //Creating an Array of Base Type int and of length 10 int i,n=0,no,x=0; static Bill object =new Bill(); //Creating an object of Bill type
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
Bill() //A default Constructor { }
public void putOrder()throws Exception //A function putOrder returning no value(void return type)with a public access specifier { System.out.println(" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); System.out.println(" Four Seasons Hotel "); System.out.println(" Menu Card "); //Displaying the MENU System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); System.out.println(" Item No. Item Rate/plate"); for(i=0;i< 10;i++){ System.out.println(" "+(i+1)+ ": "+item[i]+" "+rate[i]); }
for(int i=1;i<=1;i++){
System.out.println(" \n Enter item number from 1 to 10 to place order\n");
}x=0; while(true){if(x==10)break;
Scanner sc=new Scanner(System.in); System.out.print(" Please enter the item number :"); no=sc.nextInt(); order[x]=item[no-1]; amt[x]=rate[no-1]; System.out.print(" Please Enter the number of plates :"); no=Integer.parseInt(br.readLine()); plates[x]=no; x++; if(x>0) { System.out.print(" Any More Item ?(Y/N):"); ans=br.readLine().toUpperCase(); if(ans.equals("N")) break; } } showBill(); } //putOrder function ends here private void showBill() throws Exception{
double bamt=0,b;
System.out.println("\f");System.out.println(" You have ordered\n");System.out.println(" Item Rate No. of Plates");
for(i=0;i< x;i++) { System.out.println(" "+(i+1)+":"+order[i]+" "+amt[i]+" "+plates[i]); } while(true) { if(x< 2) break; System.out.print(" Want to cancel any item (Y/N):"); ans=br.readLine().toUpperCase(); if(ans.equals("N")) break; //If the user wants to cancell any item System.out.print(" Which item to cancel, enter item number:"); no=Integer.parseInt(br.readLine()); for(i=no-1;i< x-1;i++) { order[i]=order[i+1]; amt[i]=amt[i+1]; plates[i]=plates[i+1]; } x--; } //Displaying Bill System.out.println("\f"); System.out.println(" Cash Memo\n"); System.out.println(" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); System.out.println(" Four Seasons Hotel "); System.out.println(" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); System.out.println(" Item No. of plates Rate Amount"); System.out.println(" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); for (i=0;i< x;i++) { System.out.print(" "+order[i]+ " "+plates[i]+ " "+ amt[i]+ " "); b=plates[i]*amt[i]; System.out.println(b); bamt=bamt+b; } System.out.println(" Bill Amount Rs. "+bamt); System.out.println(" ____________________________________________________________________________________"); bamt=bamt+bamt*.125; System.out.println(" Total Amount including service charge @ 12.5% Rs. "+bamt); System.out.println(" ____________________________________________________________________________________"); System.out.println(" THANK YOU VISIT AGAIN"); System.out.println(" Press any key to continue :"); String ab=br.readLine(); }
public static void main(String[]args)throws Exception{ //Handling Exceptionsdo{
try{ object.n=0; object.i=0; object.no=0; object.ans=""; for(int y=0;y<10;y++) { object.order[y]=""; object.amt[y]=0; object.plates[y]=0; } object.putOrder(); //Calling the function putOrder System.out.print("\f"); //Clearing the Screne } catch(ArithmeticException e1) { System.out.println("Sorry some problem has occured"); } catch(ArrayIndexOutOfBoundsException e2) { System.out.println(" Sorry we dont have such item");
} catch(NumberFormatException e3) { System.out.println(" The input was not a number therfore an error has occured "); } catch(ArrayStoreException e4) { System.out.println(" Sorry some problem has occured" ); } catch(ClassCastException e5) { System.out.println(" An error has occured please run the application again"); } catch(IllegalArgumentException e6) { System.out.println(" An error has occured please run the application again"); } catch(IllegalStateException e7) { System.out.println(" An error has occured please run the application again"); } catch(IndexOutOfBoundsException e9) { System.out.println(" An error has occured please run the application again"); } catch(NegativeArraySizeException e10) { System.out.println(" An error has occured please run the application again"); } catch(NullPointerException e11) { System.out.println(" An error has occured please run the application again"); } catch(SecurityException e12) { System.out.println(" An error has occured please run the application again"); } catch(UnsupportedOperationException e13) { System.out.println(" An error has occured please run the application again"); } catch(java.util.InputMismatchException e14) { System.out.println(" The Input was wrong therfore an error has occured "); } System.out.print("\n Do you want to continue the Application(Y/N)? :"); object.ch=(char)System.in.read(); //If ch is N or n the Applications ends object.ch=Character.toUpperCase(object.ch); System.out.print("\f"); }while(object.ch!='N'); //Loop get excuited as long as ch is not equal to n or N
System.out.println("\f\n T H A N K Y O U ! !"); }}// Program Ends
Comments
Post a Comment