Loading...
Loading...
Loading...
Loading...

Simple Ordering System (Console)

View: 89    Dowload: 0   Comment: 0   Post by: daii   Category: Java Sun   Fields: none

Download  simple-ordering-system.zip (2.57 KB)

You need to Sign In to download the file simple-ordering-system.zip
If you do not have an account then Sign up for free here

I have my original program of this using the concept of stacks however, I find it difficult on updating the elements of the array. Instead of using the same concept, I've modified it and made it just to a static array with fixed elements.

I hope this program/concept could help in your activities/projects.

  1. import java.util.*;
  2.  
  3. public class cart
  4. {
  5. //To publicly access the quantity as it updates every time you wish to buy again
  6. public static int total_quantity=0;
  7. //I have declared 4 products here
  8. public static String[] products = {null, "1.) Quarter-Pounder Burger 50.00",
  9. "2.) One-Percenter (2-Stacks of Quarter Pounder Patty) 99.00",
  10. "3.) Tombstone Piledriver (3 Stacks of Quarter Pounder Patty) 150.00",
  11. "4.) God's Last Gift (Tombstone Burger with 100g of Carolina Reaper) 200.00"};
  12. //Prices in accordance of their elements
  13. public static int[] product_price ={0,50,99,150,200};
  14. //This is the cart for the check-out of all order you have
  15. public static int[] final_qty=new int[5];
  16.  
  17. public static void main(String[] args)
  18. {
  19. Scanner s = new Scanner(System.in);
  20. int choose, quantity;
  21. int p1=0;
  22. int p2=0;
  23. int p3=0;
  24. int p4=0;
  25. char decision;
  26. System.out.println("Welcome to Burger TK, please choose any of the menu there..");
  27. do
  28. {
  29.  
  30. for(int i = 0; i < products.length; i++)
  31. {
  32. if(products[i] != null)
  33. System.out.println(products[i]);
  34. }
  35.  
  36. System.out.print("Choose any item: ");
  37. choose=s.nextInt();
  38.  
  39. System.out.print("How many pieces? ");
  40. quantity=s.nextInt();
  41.  
  42. switch(choose)
  43. {
  44. case 1:
  45. p1 += quantity;
  46. final_qty[1]=p1;
  47. break;
  48.  
  49. case 2:
  50. p2 += quantity;
  51. final_qty[2]=p2;
  52. break;
  53.  
  54. case 3:
  55. p3 += quantity;
  56. final_qty[3]=p3;
  57. break;
  58.  
  59. case 4:
  60. p4 += quantity;
  61. final_qty[4]=p4;
  62. break;
  63. }
  64. System.out.print("Would you like to order again? Y/N / y/n: ");
  65. decision=s.next().charAt(0);
  66. }while(decision != 'n' && decision != 'N');
  67.  
  68. System.out.println("==Final Cart==");
  69. System.out.println("\t\\Item\t\\Qty\t\\Total");
  70. int sum=0;
  71. for(int i=0; i < final_qty.length; i++)
  72. {
  73. if(final_qty[i] != 0)
  74. {
  75. System.out.println(products[i]+"\\"+final_qty[i]+"\\"+final_qty[i]*product_price[i]);
  76. sum = sum + final_qty[i]*product_price[i];
  77. }
  78. }
  79. System.out.println("Total Purchased items: "+(p1+p2+p3+p4));
  80. System.out.println("Total Purchase: "+sum);
  81. int payment=0;
  82. do
  83. {
  84. System.out.print("Enter Payment: ");
  85. payment=s.nextInt();
  86. }while(sum > payment);
  87. System.out.println("Thank you for buying! here's your change: "+(payment-sum));
  88. }
  89.  
  90. }

PS: I have modified some of its content. I just changed the name of some products but still, it is the same program.

Simple Ordering System (Console)

I have my original program of this using the concept of stacks however, I find it difficult on updating the elements of the array. Instead of using the same concept, I've modified it and made it just to a static array with fixed elements.

Posted on 27-09-2018 

Comment:

To comment you must be logged in members.

Files with category

 
File suggestion for you
File suggestion for you
File suggestion for you
File suggestion for you
Loading...
Loading...
Loading...
Loading...
File top downloads
File top downloads
File top downloads
File top downloads
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Codetitle - library source code to share, download the file to the community
Copyright © 2018. All rights reserved. codetitle Develope by Vinagon .Ltd