Untitled

 avatar
unknown
java
3 years ago
3.9 kB
3
Indexable
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // welcome message
        System.out.println("Welcome to the Basic Clothes Shop!\n" +
                "Choose the clothes you want to buy:");
        String basket = "";
        double total = 0;
        boolean flag = true;
        while (flag)
        {
            System.out.println("1.T-shirt\n" +
                    "2.Hoodie\n" +
                    "3.Socks\n" +
                    "4.Underwear\n" +
                    "5. Check basket\n" +
                    "6. Clear basket\n" +
                    "7. Exit");
            int x = sc.nextInt();
            switch (x)
            {
                case 1:
                    System.out.println("Choose the color of shirt:\n" +
                            "1. Black - 3000kzt\n" +
                            "2. White - 3000 kzt\n" +
                            "3. exit");
                    int a = sc.nextInt();
                    switch (a)
                    {
                        case 1:
                            total += 3000;
                            System.out.println("Choose the size: \n");
                            char ch = sc.next().charAt(0);
                            basket += "Black T-shirt " + ch + " - 3000 kzt\n";
                            break;
                        case 2:
                            total += 3000;
                            System.out.println("Choose the size: \n");
                            char ch2 = sc.next().charAt(0);
                            basket += "White T-shirt " + ch2 + " - 3000 kzt\n";
                            break;
                        case 3:
                            break;
                    }
                    break;
                case 2:
                    System.out.println("Choose the color of hoodie:" +
                            "1. Black - 7000kzt" +
                            "2. White - 7000 kzt" +
                            "3. exit");
                    int b = sc.nextInt();
                    switch (b)
                    {
                        case 1:
                            total += 3000;
                            System.out.println("Choose the size: \n");
                            char ch = sc.next().charAt(0);
                            basket += "Black Hoodie" + ch + " - 7000 kzt\n";
                            break;
                        case 2:
                            total += 3000;
                            System.out.println("Choose the size: \n");
                            char ch2 = sc.next().charAt(0);
                            basket += "White Hoodie" + ch2 + " - 7000 kzt\n";
                            break;
                        case 3:
                            break;
                    }
                    break;
                case 3:
                    System.out.println("Choose the color of socks: \n");

                    break;
                case 4:
                    System.out.println("Choose the color of underwear: \n");
                    break;
                case 5:
                    System.out.println("These items in your basket: " + basket);
                    System.out.println("Total price: " + total);
                    break;
                case 6:
                    System.out.println("Basket is empty");
                    basket = "";
                    total =  0;
                    break;
                case 7:
                    flag = false;
                    break;
                default:
                    System.out.println("Wrong number");
                    break;
            }
        }
    }
}
Editor is loading...