Advertisement
wuvic21

tax

Oct 17th, 2019
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. /*
  2. Victor Wu
  3. 10/11/19
  4. Period 1
  5. Chapter 3 Lab Shopping Cart
  6. */
  7. package shoppingcart;
  8. import java.util.Scanner;
  9.  
  10.  
  11.  
  12. public class Shoppingcart {
  13.  
  14. public static void main(String[] args) {
  15. askname();
  16. locationandtotal();
  17. }
  18. public static void askname(){
  19. System.out.println("Hello! What is your name?");
  20. Scanner nameasker = new Scanner(System.in);
  21. String name = nameasker.next();
  22. System.out.println("Hello " + name + ". Where do you live?");
  23.  
  24. }
  25. public static void locationandtotal(){
  26. Scanner locationasker = new Scanner(System.in);
  27. System.out.println("Please type either Issaquah, Portland, Los Angeles, Paris, or Taipei.");
  28. String location = locationasker.next();
  29. System.out.println("You live in: " + location);
  30. Scanner itempriceasker = new Scanner(System.in);
  31. System.out.println("What is the price of the item you would like to purchase? (Type quit to end.)");
  32. for (int i = 0; i < 1;){
  33. double itemprice = itempriceasker.nextInt();
  34. System.out.println("The price of your item before taxes and tips is $" + itemprice);
  35. double tax = 0;
  36. double tip = 0;
  37. if (location.equals("Issaquah")){
  38. tax = .095;
  39. tip = .15;
  40. else if (location.equals("Portland")) {
  41. tip = .15;
  42. }
  43. else if (location.equals("Los Angeles")){
  44. tax = .09;
  45. tip = .15;
  46. else if (location.equals("Paris")){
  47. tax = .196;
  48. tip = 0;
  49. else if (location.equals("Taipei")){
  50. tax = .05;
  51. tip = 0;
  52. }
  53. }
  54. double finalprice = (itemprice*tax)+(itemprice*tip)+itemprice;
  55. System.out.println("The current tax rate in Issaquah is " + tax*100 + "%. The current tip rate is " + tip*100 + "%.");
  56. System.out.println("Your final bill is $" + finalprice + ".");
  57. }
  58. }
  59. }
  60.  
  61.  
  62. }
  63.  
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement