Question

In: Computer Science

I need know how to make A Java supermarket awards coupons depending on how much a...

 I need know how to make A  Java supermarket awards coupons depending on how much a customer spends on

  groceries. For example, if you spend $50, you will get a coupon worth eight percent

  of that amount. The following table shows the percent used to calculate the coupon

  awarded for different amounts spent. Write a program that calculates and prints the

  value of the coupon a person can receive based on groceries purchased.

* - Up to 10 dollars: No coupon
* - From 10 to 60 dollars: 8% coupon
* - From 50 to 150 dollars: 10% coupon
* - From 150 to 210 dollars: 12% coupon
* - More than 210 dollars: 14% coupon

Solutions

Expert Solution

import java.util.Scanner;

public class GroceryStore {

        public static void main(String[] args) {
                
                Scanner in = new Scanner(System.in);

                System.out.println("Enter the amount of groceries you purchased: ");
                double amount = in.nextDouble();
                
                double perc = 0;
                
                if(amount >= 210) {
                        perc = 14;
                } else if(amount >= 150) {
                        perc = 12;
                } else if(amount >= 50) {
                        perc = 10;
                } else if(amount >= 10) {
                        perc = 8;
                }
                
                double discount = amount * perc / 100;
                System.out.println("You will get coupon worth $" + discount);
                
                in.close();
        }

}
**************************************************

Thanks for your question. We try our best to help you with detailed answers, But in any case, if you need any modification or have a query/issue with respect to above answer, Please ask that in the comment section. We will surely try to address your query ASAP and resolve the issue.

Please consider providing a thumbs up to this question if it helps you. by Doing that, You will help other students, who are facing similar issue.


Related Solutions

I need know how to make A Java supermarket awards coupons depending on how much a...
I need know how to make A Java supermarket awards coupons depending on how much a customer spends on groceries. For example, if you spend $50, you will get a coupon worth eight percent of that amount. The following table shows the percent used to calculate the coupon i also need comments awarded for different amounts spent. Write a program that calculates and prints the value of the coupon a person can receive based on groceries purchased. * - Up...
I need to know how to make an ethical decision in detail?
I need to know how to make an ethical decision in detail?
QUESTION 1 How much of a yearly investment would I need to make to earn $500,000...
QUESTION 1 How much of a yearly investment would I need to make to earn $500,000 in 30 years at 9% interest> A. $8,573.77 B. $617.98 C. $10,437.20 D. $3,668.18 10 points    QUESTION 2 If you wanted your monthly payment to be $700 per month on a loan that extends for 72 months at 8% interest, what is the amount you could borrow? A. $59,667.19 B. $44,864.38 C. $39,924.17 D. $27,637.54
My Java program keeps "running." I know I need to close a "loop" but I can't...
My Java program keeps "running." I know I need to close a "loop" but I can't find it. I'm learning how to code. This is confusing for me. import java.util.Scanner; import java.util.ArrayList; public class SteppingStone4_Loops {    public static void main(String[] args) { Scanner scnr = new Scanner(System.in); String recipeName = ""; ArrayList<String> ingredientList = new ArrayList(); String newIngredient = ""; boolean addMoreIngredients = true; System.out.println("Please enter the recipe name: "); recipeName = scnr.nextLine();    do {    System.out.println("Would you...
I need to make JAVA program that calculates the area of a brick of a specific...
I need to make JAVA program that calculates the area of a brick of a specific color. I have class Brick with the following UML: String color int number int length int width I made methods: getColor(), getNumber(), getLength(), getWidth() in the class Brick So it starts like this: ##### public Brick(String color, int number, int length, int width) { this.color = color; this.number = number; this.length = length; this.width = width;    }   public String toString() {   return number...
I need to make this into a Java Code: Write a program that prompts the user...
I need to make this into a Java Code: Write a program that prompts the user for a double value representing a radius. You will use the radius to calculate: circleCircumference = 2πr circleArea = πr2 sphereArea = 4πr2 sphereVolume = 43πr3 You must use π as defined in the java.lang.Math class. Your prompt to the user to enter the number of days must be: Enter radius: Your output must be of the format: Circle Circumference = circleCircumference Circle Area...
Make a java program of Mickey I have the starter program but I need to add...
Make a java program of Mickey I have the starter program but I need to add eyes and a smile to it. import java.awt.Canvas; import java.awt.Color; import java.awt.Graphics; import java.awt.Rectangle; import javax.swing.JFrame; public class Mickey extends Canvas { public static void main(String[] args) { JFrame frame = new JFrame("Mickey Mouse"); Canvas canvas = new Mickey(); canvas.setSize(400, 400); canvas.setBackground(Color.white); frame.add(canvas); frame.pack(); frame.setVisible(true); } public void paint(Graphics g) { Rectangle bb = new Rectangle(100, 100, 200, 200); mickey(g, bb); } public void...
Using java, I need to make a program that reverses a file. The program will read...
Using java, I need to make a program that reverses a file. The program will read the text file character by character, push the characters into a stack, then pop the characters into a new text file (with each character in revers order) EX: Hello World                       eyB       Bye            becomes    dlroW olleH I have the Stack and the Linked List part of this taken care of, I'm just having trouble connecting the stack and the text file together and...
So I need to make a java program that reverse or replace first or lastchar or...
So I need to make a java program that reverse or replace first or lastchar or remove char from user's string input. length, concat, charAt, substring, and equals (or equalsIgnoreCase) thses are the string method that only I can use for example if user put asdf asdf and chose reverse input should be fdsa fdsa if user put asdf asdf and chose replace first a with b input should be bsdf asdf if user put asdf asdf and chose remove...
how can i find the number of linear discriminant functions? I need to know how i...
how can i find the number of linear discriminant functions? I need to know how i can find out if there is one function, two functions, more? how do i know how many LDF's are there?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT