Computer Applications
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:
Sl. No. Name Ticket Charges Discount Net Amount
(Assume that there are 15 customers, first customer is given the serial no (SI. No.) 1, next customer 2 …….. and so on)
Java
Java Conditional Stmts
ICSE 2010
89 Likes
Answer
import java.util.Scanner;
public class KboatShashaTravels
{
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
String names[] = new String[15];
int amounts[] = new int[15];
for (int i = 0; i < 15; i++) {
System.out.print("Enter " + "Customer " + (i+1) + " Name: ");
names[i] = in.nextLine();
System.out.print("Enter " + "Customer " + (i+1) + " Ticket Charges: ");
amounts[i] = in.nextInt();
in.nextLine();
}
System.out.println("Sl. No.\tName\t\tTicket Charges\tDiscount\t\tNet Amount");
for (int i = 0; i < 15; i++) {
int dp = 0;
int amt = amounts[i];
if (amt > 70000)
dp = 18;
else if (amt >= 55001)
dp = 16;
else if (amt >= 35001)
dp = 12;
else if (amt >= 25001)
dp = 10;
else
dp = 2;
double disc = amt * dp / 100.0;
double net = amt - disc;
System.out.println((i+1) + "\t" + names[i]
+ "\t" + amounts[i] + "\t\t"
+ disc + "\t\t" + net);
}
}
}Output

Answered By
36 Likes
Related Questions
Using the switch-case statement, write a menu driven program to do the following:
(a) To generate and print Letters from A to Z and their Unicode
Letters Unicode A 65 B 66 . . . . . . Z 90 (b) Display the following pattern using iteration (looping) statement:
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5Write a program to input three numbers (positive or negative). If they are unequal then display the greatest number otherwise, display they are equal. The program also displays whether the numbers entered by the user are 'All positive', 'All negative' or 'Mixed numbers'.
Sample Input: 56, -15, 12
Sample Output:
The greatest number is 56
Entered numbers are mixed numbers.A student executes the following program segment and gets an error. Identify the statement which has an error, correct the same to get the output as WIN.
boolean x = true; switch(x) { case 1: System.out.println("WIN"); break; case 2: System.out.println("LOOSE"); }