Computer Applications
A Mega Shop has different floors which display varieties of dresses as mentioned
below:
- Ground floor : Kids Wear
- First floor : Ladies Wear
- Second floor : Designer Sarees
- 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
Answered By
36 Likes
Related Questions
The Simple Interest (SI) and Compound Interest (CI) of a sum (P) for a given time (T) and rate (R) can be calculated as:
(a) SI = (p * r * t) / 100
(b) CI = P * ((1 + (R / 100))T - 1)
Write a program to input sum, rate, time and type of Interest ('S' for Simple Interest and 'C' for Compound Interest). Calculate and display the sum and the interest earned.
The equivalent resistance of series and parallel connections of two resistances are given by the formula:
(a) R1 = r1 + r2 (Series)
(b) R2 = (r1 * r2) / (r1 + r2) (Parallel)
Using a switch case statement, write a program to enter the value of r1 and r2. Calculate and display the equivalent resistances accordingly.
Using a switch case statement, write a menu driven program to convert a given temperature from Fahrenheit to Celsius and vice-versa. For an incorrect choice, an appropriate message should be displayed.
Hint: c = 5/9(f-32) and f=1.8c+32
The volume of solids, viz. cuboid, cylinder and cone can be calculated by the formula:
- Volume of a cuboid (v = l*b*h)
- Volume of a cylinder (v = π*r2*h)
- Volume of a cone (v = (1/3)*π*r2*h)
Using a switch case statement, write a program to find the volume of different solids by taking suitable variables and data types.