icse-promo

Question

Shasha Travels Pvt. Ltd. gives the following discount to its customers:
Ticket amount Discount
Above Rs 70000 – 18%
Rs 55001 to Rs 70000 – 16%
Rs 35001 to Rs 55000 – 12%
Rs 25001 to Rs 35000 – 10%
less than Rs 25001 – 2%

Write a program to input the name and ticket amount for the customer and calculate the discount amount and net amount to be paid. Display the output in  the following format for each customer :

(Assume that there are 15 customers, first customer is given the serial no (SlNo.) 1, next customer 2 … and so on.

				
					SL.NO. Name Ticket charges Discount Net amount 1
-       -     -              -        -
				
			

(Assume that there are 15 customers, first customer is given the serial no (SlNo.) 1, next customer 2 … and so on.

Share code with your friends

Share on whatsapp
Share on facebook
Share on twitter
Share on telegram

Code

				
					import java.util.Scanner;
public class Program6
{
    public static void main(String[] args)
    {

        String name[];
        double amount[];
        double discount=0,net=0;
        int i=0;
        Scanner sc = new Scanner(System.in);
        name=new String[15];
        amount=new double[15];
        for(i=0;i<15;i++)
        {
            System.out.println("Customer:"+(i+1));

            System.out.print("Enter name: ");
            name[i] = sc.nextLine();
            System.out.print("Enter ticket amount: ");
            amount[i] = sc.nextDouble();
            sc.nextLine();
        }

        System.out.println("Sl. No.\t Name \t Charges \t Discount \t Net Amount");

        for(i=0;i<15;i++)
        {
            if(amount[i] > 70000)
            {
                discount = 0.18*amount[i];
            }
            else if(amount[i] >= 55001 && amount[i] <= 70000)
            {
                discount = 0.16*amount[i];

            }
            else if(amount[i] >= 35001 && amount[i] <= 55000)
            {
                discount = 0.12*amount[i];
            }
            else if (amount[i] >= 25001 && amount[i] <= 35000)
            {
                discount = 0.10*amount[i];
            }
            else if (amount[i] <= 25000)
            {
                discount = 0.02*amount[i];
            }

            net = amount[i] - discount;
            System.out.println((i+1) + "\t" + name[i] +"\t" + amount[i] + "\t" + discount + "\t" + net);
        }

    }
}

				
			

Coding Store

Leave a Reply

Your email address will not be published. Required fields are marked *