Computer Applications
Mayur Transport Company charges for parcels as per the following tariff:
Weight | Charges |
---|---|
Upto 10 Kg. | Rs. 30 per Kg. |
For the next 20 Kg. | Rs. 20 per Kg. |
Above 30 Kg. | Rs. 15 per Kg. |
Write a program in Java to calculate the charge for a parcel, taking the weight of the parcel as an input.
Answer
import java.util.Scanner;
public class KboatMayurTpt
{
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.print("Enter parcel weight: ");
double wt = in.nextDouble();
double amt = 0;
if (wt <= 10)
amt = 30 * wt;
else if (wt <= 30)
amt = 300 + ((wt - 10) * 20);
else
amt = 300 + 400 + ((wt - 30) * 15);
System.out.println("Parcel Charge = " + amt);
}
}
Output
Related Questions
Employees at Arkenstone Consulting earn the basic hourly wage of Rs.500. In addition to this, they also receive a commission on the sales they generate while tending the counter. The commission given to them is calculated according to the following table:
Total Sales Commmision Rate Rs. 100 to less than Rs. 1000 1% Rs. 1000 to less than Rs. 10000 2% Rs. 10000 to less than Rs. 25000 3% Rs. 25000 and above 3.5% Write a program in Java that inputs the number of hours worked and the total sales. Compute the wages of the employees.
The electricity board charges the bill according to the number of units consumed and the rate as given below:
Units Consumed Rate Per Unit First 100 units 80 Paisa per unit Next 200 units Rs. 1 per unit Above 300 units Rs. 2.50 per unit Write a program in Java to accept the total units consumed by a customer and calculate the bill. Assume that a meter rent of Rs. 500 is charged from the customer.
Create a program in Java to find out if a number entered by the user is a Duck Number.
A Duck Number is a number which has zeroes present in it, but there should be no zero present in the beginning of the number. For example, 6710, 8066, 5660303 are all duck numbers whereas 05257, 080009 are not.