A paper roll manufacturing company offers discount to the dealer and retailer based on the length of the paper roll as per the following criteria: Length of the paper Dealer Retailer Up to 10 Meters 10% 8% 11 Meters and up to 20 meters 15% 10% 21 Meters and up to 50 meters 18% 14% More than 50 meters 20% 15% Write a program to input the length of paper roll in Meters and the number of rolls purchased. Rate of paper per Meter is Rs 12. Use menu driven approach having choices (1) for dealer and (2) for retailer to find and print the amount to be paid to the company after discount
Answers
Answer:
import java.util.Scanner;
public class KboatDiscount
{
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.print("Enter Cloth length: ");
int l = in.nextInt();
System.out.print("Enter Total Amount of purchase: ");
double a = in.nextDouble();
System.out.println("Enter D for Dealer: ");
System.out.println("Enter R for Retailer: ");
System.out.print("Enter customer type: ");
char type = in.next().charAt(0);
type = Character.toUpperCase(type);
int d = 0;
switch (type) {
case 'D':
if (l <= 1000)
d = 20;
else if (l <= 2000)
d = 25;
else
d = 35;
break;
case 'R':
if (l <= 1000)
d = 15;
else if (l <= 2000)
d = 20;
else
d = 25;
break;
default:
System.out.println("Wrong choice");
}
double disc = a * d / 100.0;
double amt = a - disc;
System.out.println("Amount to be paid = " + amt);
}
}