8.5k views
5 votes
A video club wants to reward its best members with a discount based on the member’s number of movie rentals and the number of new members referred by the member. The discount is in percent and is equal to the sum of the rentals and the referrals, but it cannot exceed 75 percent. (Hint: Math.min.) Write a program DiscountCalculator to calculate the value of the discount.

User Kelvt
by
2.8k points

2 Answers

4 votes

Final answer:

To calculate the value of the discount for the video club's best members, you can use the formula: discount = Math.min(rentals + referrals, 75). This formula ensures that the discount does not exceed 75 percent.

Step-by-step explanation:

To calculate the value of the discount for the video club's best members, you can use the formula: discount = Math.min(rentals + referrals, 75). This formula ensures that the discount does not exceed 75 percent. Here's how you can write the program:

public class DiscountCalculator {

public static void main(String[] args) {
int rentals = 4; // insert the number of movie rentals
int referrals = 2; // insert the number of new members referred
int discount = Math.min(rentals + referrals, 75);
System.out.println("The value of the discount is: " + discount + "%");
User Coffee Bite
by
4.0k points
3 votes

Answer:

public class MovieRental

{

public static void main(String[] args)

{

Scanner in = new Scanner(System.in);

System.out.print("Enter the number of movie rentals: ");

int movieRentals = in.nextInt();

System.out.print("Enter the number of members referred to the video club: ");

int memberReferral = in.nextInt();

in.close();

double discountVal = Math.min(movieRentals + memberReferral, 75);

System.out.println("The discount is equal to: " + discountVal);

}

}

User Joelmc
by
3.2k points