Advertisement
N3ggg

Untitled

Mar 17th, 2020
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.78 KB | None | 0 0
  1. import java.util.*;
  2. public class Main {
  3.  
  4. public static void main(String[] args) {
  5. int k =0;
  6. Scanner keyboard = new Scanner(System.in);
  7. System.out.println("Ye Olde Keychain Shoppe");
  8. System.out.println();
  9. int choice = 0;
  10. int price = 10;
  11. double tax = 0.0825;
  12. int ship = 5;
  13. int pership = 1;
  14. while(choice !=4){
  15. System.out.println("1. Add Keychains to Order");
  16. System.out.println("2. Remove Keychains from Order");
  17. System.out.println("3. View Current Order");
  18. System.out.println("4. Checkout");
  19. System.out.println();
  20. System.out.print("Please enter your choice: ");
  21. choice = keyboard.nextInt();
  22.  
  23. if(choice == 1){
  24. k=add_keychains(k);
  25. System.out.println();
  26. }else if(choice ==2){
  27. k = remove_keychains(k);
  28. System.out.println();
  29. }else if(choice==3){
  30. view_order(k,tax,ship,pership,price);
  31. System.out.println();
  32. }else if(choice==4){
  33. Scanner s = new Scanner(System.in);
  34. System.out.println();
  35. System.out.println("CHECKOUT");
  36. System.out.println();
  37. System.out.print("What is your name? ");
  38. String name = s.next();
  39. view_order(k,tax,ship,pership,price);
  40. System.out.print("Thanks for your order, "+name);
  41. System.out.println();
  42. }
  43. }
  44.  
  45. }
  46. public static int add_keychains(int k){
  47. Scanner s = new Scanner(System.in);
  48. System.out.print("You have "+k+" keychains. How many to add? ");
  49. int add = s.nextInt();
  50. k = k+add;
  51. System.out.println("You now have "+k+" keychains.");
  52. return k;
  53. }
  54. public static int remove_keychains(int k){
  55. Scanner s = new Scanner(System.in);
  56. System.out.print("You now have "+k+" keychains. How many to remove? ");
  57. int remove = s.nextInt();
  58. int remain = k - remove;
  59. System.out.println("You now have "+remain+" keychains.");
  60. return remain;
  61. }public static void view_order(int k, double tax, int ship, int pership, double price ){
  62. System.out.println("You now have "+k+" keychains.");
  63. System.out.println("Keychains cost $10 each.");
  64. System.out.println("The shipping charges on the order "+ship);
  65. price = k*10.00;
  66. System.out.println("The subtotal before tax "+price+".");
  67. System.out.println("The tax on the order "+tax);
  68. double total= price+tax*price+pership+ship;
  69. System.out.println("The final cost of the order is "+total);
  70. }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement