title: Java Restaurant Billing System
body: <p>I am a beginner in Java and am trying to make a simple restaurant billing system with data extracted from database</p>
  
  <p>This is My database extraction</p>
  
  <pre><code>String driver = "com.mysql.cj.jdbc.Driver";
  String url = "jdbc:mysql://localhost:3306/restaurant?useTimezone=true&amp;serverTimezone=UTC";
  String username ="root";
  String password = "";
  Scanner sc=new Scanner(System.in);
  Class.forName(driver);
  boolean again = true;
  boolean again1 = true;
  String yes;
  ArrayList&lt;String&gt; name=new ArrayList&lt;String&gt;();
  ArrayList&lt;Double&gt; price=new ArrayList&lt;Double&gt;();
  ArrayList&lt;String&gt; materials=new ArrayList&lt;String&gt;();
  ArrayList&lt;Double&gt; cost=new ArrayList&lt;Double&gt;();
  HashMap&lt;Integer,Integer&gt; Oders=new HashMap&lt;Integer,Integer&gt;();
  Connection conn = DriverManager.getConnection(url,username,password);
  
  Statement myStmt = conn.createStatement();
  ResultSet rs = myStmt.executeQuery("select * from food");
  
      while (rs.next()) {
      String  nam= rs.getString("name");
      double  pric=rs.getDouble("price");
      String  mat= rs.getString("materials");
      double  cos=rs.getDouble("cost");
  
      name.add(nam);
      price.add(pric);
      materials.add(mat);
      cost.add(cos);
  
  }
  </code></pre>
  
  <p>and this is my calculation </p>
  
  <pre><code>while(again = true){
      System.out.println("Please press y to diplay menu");
  
      String c=sc.next();
      char ch=c.charAt(0);
      if(ch=='y'||ch=='Y'){
          System.out.println("--------------BEMS Resturant Menu Card----------------");
          for(int i=0;i&lt;name.size();i++){
              System.out.print(i+"."+name.get(i));
              for(int j=0;j&lt;price.size();j++){
                  System.out.println(":Rm"+price.get(i));
                  break;
              }
          }
          System.out.println("");
          System.out.println("Enter your choice");
          System.out.println("--------------------------------------------------");
          while(again1 = true){
              int choice=sc.nextInt();
              System.out.println("Enter the quantity");
              int quantity=sc.nextInt();
              if(choice&lt;=name.size()){
                  if(Oders.containsKey(choice)){
                      System.out.println("Choice already present increasing the quantity for "+name.get(choice));
                      System.out.println("");
                      Oders.put(choice, Oders.get(choice)+quantity);
  
                  }else{
              Oders.put(choice, quantity);
                  }
              }else{
                  System.out.println("The pressed choice does not exist in menu,enter valic choice");
                  System.out.println("");
              }
              System.out.println("Wanna order something more");
              System.out.println("press Y to add more or any random key to Check Out!");
              String c1=sc.next();
              char ch1=c1.charAt(0);
              if(ch1=='y'||ch1=='Y'){
                  System.out.println("Enter your choice");
              }else{
                  String bill ="";
                  String Total_Materials ="";
                  double Total_Cost = 0;
                  double Total_Bill= 0;
                  double Total_Profit= 0;
                  double pre =0;
                  System.out.println("no more items to be ordered----&gt;preparing final bill");
  
                  System.out.println("--------------------BEMS Restaurant-------------------"
                          + "");
  
                  System.out.println("Items ordered are");
                  System.out.println("--------------------------------------------------");
                  int count=1;
                  for (int key : Oders.keySet()) {
                      System.out.println(count+"."+name.get(key)+" : "+price.get(key)+" x "+Oders.get(key));
                      Total_Materials = Total_Materials+materials.get(key);
                      Total_Cost = Total_Cost+cost.get(key);
                      Total_Bill=Total_Bill+(price.get(key))*Oders.get(key);
                      bill =bill+ name.get(key);
                      pre = Total_Bill * 0.06;
                      Total_Bill = Total_Bill + pre;
                      Total_Profit =Total_Bill - Total_Cost;
                      count++;
                  }
                  System.out.println("--------------------------------------------------");
                  System.out.println("Total Bill : Rm."+Total_Bill);
                  System.out.println("Total SST : Rm."+ pre);
                  System.out.println("Materials Used: "+Total_Materials );
                  System.out.println("Total Cost: "+Total_Cost );
                  System.out.println("Total Profit: "+Total_Profit );
              }
  
          }
  
  
      } else{
          System.out.println("Exiting, that is invalid input,please try again");
          sc.close();
      }
  
  
  }
  </code></pre>
  
  <p>I can get the result for each transaction but how do I get result for each day </p>
  
  <p>Any Answers would be very helpful ,Thank You.</p>