Sunday, 12 March 2023

3. A car accessories shop assigns code 1 to seat covers, 2 to steering wheel covers , 3 to car lighting and 4 for air purifiers. All other items have code 5 or more. While selling the goods, a sales tax of 2% to seat covers ,3% to steering wheel covers, 4% to car lighting, 2.5% to air purifiers and 1.2% for all other items is charged. A list containing the product code and price is given for making a bill. Write a java program using switch statements to prepare a bill.



import java.util.*;

class Program3
{
    public static void main(String args[])
    {
        System.out.println("1. seat cover: 1000rs\n2. steering wheel: 1500rs");
        System.out.println("3. car lighting: 2000rs\n4. air purrfiers:1200rs");
        System.out.println("5. other items: ");
       
        int ch;
        double amount;
        System.out.print("\nenter your choice: ");
        Scanner sc = new Scanner(System.in);
        ch = sc.nextInt();
       
        switch(ch)
        {
            case 1: amount = 1000 + (1000 * 2) / 100;
                    System.out.println("seat cover total charges: " + amount);
                    break;
                   
            case 2: amount = 1500 + (1500 * 3) / 100;
                    System.out.println("steering wheel total charges: " + amount);
                    break;
                   
            case 3: amount = 2000 + (2000 * 4) / 100;
                    System.out.println("car lighting total charges: " + amount);
                    break;
                   
            case 4: amount = 1200 + (1200 * 2.3) / 100;
                    System.out.println("air purifiers: " + amount);
                    break;
                   
            case 5: System.out.print("\nenter item name: ");
                    String str = sc.next();
                   
                    System.out.print("enter amount: ");
                    amount = sc.nextDouble();
                   
                    amount = amount + (amount * 1.2) / 100;
                    System.out.println("total charges is: " + amount);
                    break;
                   
            default : System.out.print("\n--> enter valid choice <--");
        }
    }
}


No comments:

Post a Comment

python programs

1. sum of two number