Advertisement
wuvic21

chapter3lab2

Oct 11th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 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. double itemprice = itempriceasker.nextInt();
  33. System.out.println("The price of your item before taxes and tips is " + itemprice);
  34. double tax = 0;
  35. double tip = 0;
  36. if (location.equals("Issaquah")){
  37. tax += .095;
  38. tip += .15;
  39. }
  40. double finalprice = (itemprice*tax)+(itemprice*tip)+itemprice;
  41. System.out.println("The current tax rate in Issaquah is " + tax*100 + "%. The current tip rate is " + tip*100 + "%.");
  42. System.out.println("Your final bill is $" + finalprice);
  43.  
  44.  
  45. }
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement