KnowledgeBoat Logo

Computer Applications

A Mega Shop has different floors which display varieties of dresses as mentioned
below:

  1. Ground floor : Kids Wear
  2. First floor : Ladies Wear
  3. Second floor : Designer Sarees
  4. Third Floor : Men's Wear

The user enters floor number and gets the information regarding different items of the Mega shop. After shopping, the customer pays the amount at the billing counter and the shopkeeper prints the bill in the given format:

Name of the Shop: City Mart
Total Amount:
Visit Again!!

Write a program to perform the above task as per the user's choice.

Java

Java Conditional Stmts

97 Likes

Answer

import java.util.Scanner;

public class KboatMegaShop
{
    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        System.out.println("1. Ground floor");
        System.out.println("2. First floor");
        System.out.println("3. Second floor");
        System.out.println("4. Third floor");

        System.out.print("Select a floor: ");
        int floor = in.nextInt();

        boolean isFloorValid = true;

        switch (floor) {
            case 1:
                System.out.println("Kids Wear");
                break;
            case 2:
                System.out.println("Ladies Wear");
                break;
            case 3:
                System.out.println("Designer Sarees");
                break;
            case 4:
                System.out.println("Men's Wear");
                break;
            default:
                isFloorValid = false;
                System.out.println("Incorrect Floor");
                break;
        }

        if (isFloorValid) {
            System.out.print("Enter bill amount: ");
            double amt = in.nextDouble();

            System.out.println("Name of the Shop: City Mart");
            System.out.println("Total Amount: " + amt);
            System.out.println("Visit Again!!");
        }
    }
}

Variable Description Table

Program Explanation

Output

BlueJ output of A Mega Shop has different floors which display varieties of dresses as mentioned below: (a) Ground floor : Kids Wear (b) First floor : Ladies Wear (c) Second floor : Designer Sarees (d) Third Floor : Men's Wear The user enters floor number and gets the information regarding different items of the Mega shop. After shopping, the customer pays the amount at the billing counter and the shopkeeper prints the bill in the given format: Name of the Shop: City Mart Total Amount: Visit Again!! Write a program to perform the above task as per the user's choice.

Answered By

36 Likes


Related Questions