Loading...

Simple Ordering System (Console)

View: 64    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

  • Simple Ordering System (Console)

    Simple Ordering System (Console)

    View: 64    Download: 0   Comment: 0

    Category: Java Sun     Fields: none

    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.

  • Scientific Calculator –Tutorial NetBeans IDE

    Scientific Calculator –Tutorial NetBeans IDE

    View: 69    Download: 0   Comment: 0

    Category: Java Sun     Fields: none

    1. Download the zip file of SCIENTIFIC CALCULATOR–Tutorial. 2. Install your Java NetBeans IDE. 3. Open the install NetBeans. 4. Go to File. 5. Select Import project. 6. Choose from Zip ; since it is a zip file. Contact (+233) 244644700 Mail:...

  • Subnet Calculator

    Subnet Calculator

    View: 98    Download: 1   Comment: 0

    Category: Java Sun     Fields: none

    If your searching about a subnet calculator then you literally know about subnetting.

  • Very Basic Java Fighting Game

    Very Basic Java Fighting Game

    View: 122    Download: 5   Comment: 0

    Category: Java Sun     Fields: none

    Sharing you the source code of this simple fighting game created in java[eclipse]. You will learn character animation, basic interaction and some AI implementation. If you have some questions just spam me at mark[dot]cabalar[at]yahoo[dot]com. Visit...

  • Very Basic Java Game programming - Part 1

    Very Basic Java Game programming - Part 1

    View: 90    Download: 2   Comment: 0

    Category: Java Sun     Fields: none

    I don’t know how exactly to start or make an introduction for this post. I just made in to the concept of designing a simple fighting game tutorial - from doing the character animation to its overall functionality. This tutorial is intended for...

  • Recharge App (Like Paytm)

    Recharge App (Like Paytm)

    View: 112    Download: 2   Comment: 0

    Category: Java Sun     Fields: none

    Hello Dear, This is a recharge app you can recharge your mobile, electricity bill, insurance, gas bill, landline bill, etc. I have wallet functionality which you can add money in your wallet and recharge mobile using wallet amount. I have Admin...

  • Credit Card Number Verifier

    Credit Card Number Verifier

    View: 85    Download: 0   Comment: 0

    Category: Java Sun     Fields: none

    It's a JAVAFXML app that verifies if a number is a valid credit card number. It uses Luhn algorithm to verify. It also predicts the last credit card number given 15 numbers.

  • Cabin Assigner Pro

    Cabin Assigner Pro

    View: 110    Download: 0   Comment: 0

    Category: Java Sun     Fields: none

    This program allows to create and assign cabins at summer camp. There are error checking features including setting a capacity, an alert if a child is assigned to a cabin outside of their age range, it will prohibit assigned a cabin that is set for...

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