Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Victor Wu
- 10/11/19
- Period 1
- Chapter 3 Lab Shopping Cart
- */
- package shoppingcart;
- import java.util.Scanner;
- public class Shoppingcart {
- public static void main(String[] args) {
- askname();
- locationandtotal();
- }
- public static void askname(){
- System.out.println("Hello! What is your name?");
- Scanner nameasker = new Scanner(System.in);
- String name = nameasker.next();
- System.out.println("Hello " + name + ". Where do you live?");
- }
- public static void locationandtotal(){
- Scanner locationasker = new Scanner(System.in);
- System.out.println("Please type either Issaquah, Portland, Los Angeles, Paris, or Taipei.");
- String location = locationasker.next();
- System.out.println("You live in: " + location);
- Scanner itempriceasker = new Scanner(System.in);
- System.out.println("What is the price of the item you would like to purchase? (Type quit to end.)");
- for (int i = 0; i < 1;){
- double itemprice = itempriceasker.nextInt();
- System.out.println("The price of your item before taxes and tips is $" + itemprice);
- double tax = 0;
- double tip = 0;
- if (location.equals("Issaquah")){
- tax = .095;
- tip = .15;
- else if (location.equals("Portland")) {
- tip = .15;
- }
- else if (location.equals("Los Angeles")){
- tax = .09;
- tip = .15;
- else if (location.equals("Paris")){
- tax = .196;
- tip = 0;
- else if (location.equals("Taipei")){
- tax = .05;
- tip = 0;
- }
- }
- double finalprice = (itemprice*tax)+(itemprice*tip)+itemprice;
- System.out.println("The current tax rate in Issaquah is " + tax*100 + "%. The current tip rate is " + tip*100 + "%.");
- System.out.println("Your final bill is $" + finalprice + ".");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement