Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Coupon {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- //Varibles
- double spent;
- double coupon;
- //Input from keyboard
- System.out.println("Please enter the cost of your groceries: ");
- spent = input.nextDouble();
- //Calculate discount
- if (spent<10)
- System.out.print("You did not earn a discount");
- else if (spent>10 && spent<=60) {
- coupon = spent * 0.08;
- System.out.print("You win a discount coupon of " + coupon + "(8% of your purchase)");
- }
- else if (spent>60 && spent<=150) {
- coupon = spent * 0.1;
- System.out.print("You win a discount coupon of " + coupon + "(10% of your purchase)");
- }
- else if (spent>150 && spent<=210) {
- coupon = spent * 0.12;
- System.out.print("You win a discount coupon of " + coupon + "(12% of your purchase)");
- }
- else if (spent>210) {
- coupon = spent * 0.14;
- System.out.print("You win a discount coupon of " + coupon + "(14% of your purchase)");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement