Computer Science, asked by Rahulsunny303, 1 year ago

wap to input the name and ticket amount for the customer (using scanner class) and calculate the discount amount and net amount to be paid.

Attachments:

Answers

Answered by Swebo
18
import java.util.Scanner;

 

public class Ticket {

 

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        for (int i = 1; i <= 15; i++) {

            System.out.print("Enter Name: ");

            String name = scanner.nextLine();

            System.out.print("Enter ticket charges: ");

            double ticketCharges = scanner.nextDouble();

            System.out.print("Enter discount%: ");

            double discountPercent = scanner.nextDouble();

            scanner.nextLine();

            double discount = (discountPercent / 100 * ticketCharges);

            double netAmount = ticketCharges - discount;

            System.out.println();

            System.out.println("--- TICKET ---");

            System.out.println("Sr No: " + i);

            System.out.println("Name: " + name);

            System.out.println("Ticket Charges: " + ticketCharges);

            System.out.println("Discount%: " + discountPercent);

            System.out.println("Discount: " + discount);

            System.out.println("Net Amount: " + netAmount);

            System.out.println("-------------");

            System.out.println();

        }

    }

}


Similar questions