Question

A supermarket awards coupons depending on how much a customer spends on groceries. For example, if you spend $50, you will ge
0 0
Add a comment Improve this question Transcribed image text
Answer #1

SOLUTION =>

import java.util.*;
import java.lang.*;
import java.io.*;


public class GroceryCoupon
{
   public static void main (String[] args) throws java.lang.Exception
   {
       System.out.println("Please enter the cost of your groceries : ");
       Scanner sc = new Scanner(System.in);
       double discount = 0;
       int n = sc.nextInt();
       if(n<10)
       {
       System.out.println("No Coupon");
       }
       else if(n>=10 && n<=60)
       {
       discount = (double)n/(double)100 * (double)8;
       System.out.println("You win a discount coupon of $ "+ discount +" (8% of your purchase)");
       }
       else if(n>60 && n<=150)
       {
       discount = (double)n/(double)100 * (double)10;
       System.out.println("You win a discount coupon of $ "+ discount +" (10% of your purchase)");
       }
       else if(n>150 && n<=210)
       {
       discount = (double)n/(double)100 * (double)12;
       System.out.println("You win a discount coupon of $ "+ discount +" (12% of your purchase)");
       }
       else if(n>210)
       {
       discount = (double)n/(double)100 * (double)14;
       System.out.println("You win a discount coupon of $ "+ discount +" (14% of your purchase)");
       }
   }
}

- x GroceryCoupon - Notepad File Edit Format View Help public lass GroceryCoupon public static void main (String[] args) thro

C:\Users\pragya saraswat\Desktop>javac GroceryCoupon.java C:\Users\pragya saraswat\Desktop>java GroceryCoupon Please enter th

Add a comment
Know the answer?
Add Answer to:
A supermarket awards coupons depending on how much a customer spends on groceries. For example, if...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Lab Assignment Objectives: Translate a basic application statement into a software selection solution. Learn how to...

    Lab Assignment Objectives: Translate a basic application statement into a software selection solution. Learn how to design and implement a simple program control structure. Use logical operators and boolean variables to set up test conditions. Construct applicable test cases to test your programs for correctness. Understand the Application You will obtain a grocery bill total from the customer. Depending on the amount of the grocery bill a coupon rewards amount will be calculated. The user will be informed of the...

  • Assignment 14.3: Valid Email (10 pts) image source Write a program that takes as input an...

    Assignment 14.3: Valid Email (10 pts) image source Write a program that takes as input an email address, and reports to the user whether or not the email address is valid. For the purposes of this assignment, we will consider a valid email address to be one that contains an @ symbol The program must allow the user to input as many email addresses as desired until the user enters "q" to quit. For each email entered, the program should...

  • please explain all the steps. I need it ASAP. i will give u good ratings. Do...

    please explain all the steps. I need it ASAP. i will give u good ratings. Do in java file Queues are often used to simulate the flow of people, cars, airplanes, transactions, and so on. Write a program that models checkout lines at a supermarket, using the Queue class from the queue.java program (Listing 4.4). Several lines of customers should be displayed; you can use the display, insertſ), and remove() method. You can add a new customer by pressing a...

  • ArrayQueue

    Implement the ArrayQueue classIn the ‘Queues’ lecture, review the ‘Introduce next lab’ section.  See here that we can use a circular array to implement the queue data structure.  You must write a class named ArrayQueue that does this.ArrayQueue will be a generic class, that implements our generic QueueInterface interface.  This demonstrates the Java interface feature, where we have already implemented queue dynamically, using the LinkedQueue class covered during the lecture.Many classes are given to youDownload and unzip the Circular array project from Canvas, ‘Queues’ module, Example programs.  Open the project in...

  • In this assignment you are to utilize the Node data structure provided on Blackboard. In this...

    In this assignment you are to utilize the Node data structure provided on Blackboard. In this assignmet you are to write a main program that implements two methods and a main method as their driver. So, only main and two methods with it. Note: You may not use any of the LinkedList class provided on Blackboard, you may use the methods in it as a guide (you should actually look at them) but you cannot use any of the methods...

  • JAVA Objective : • Learning how to write a simple class. • Learning how to use...

    JAVA Objective : • Learning how to write a simple class. • Learning how to use a prewritten class. • Understanding how object oriented design can aid program design by making it easier to incorporate independently designed pieces of code together into a single application. Instructions: • Create a project called Lab13 that contains three Java file called Book.java , Bookstore.java and TempleBookstore.java • I’ve provided a screenshot of how your project should look like. • Be sure to document...

  • package _solution; /** This program demonstrates how numeric types and operators behave in Java Do Task...

    package _solution; /** This program demonstrates how numeric types and operators behave in Java Do Task #1 before adding Task#2 where indicated. */ public class NumericTypesOriginal { public static void main (String [] args) { //TASK #2 Create a Scanner object here //identifier declarations final int NUMBER = 2 ; // number of scores int score1 = 100; // first test score int score2 = 95; // second test score final int BOILING_IN_F = 212; // boiling temperature double fToC;...

  • Question 1 2 pts The preprocessor executes after the compiler. False True Question 2 2 pts...

    Question 1 2 pts The preprocessor executes after the compiler. False True Question 2 2 pts What code is human-readable and follows the standards of a programming language? Secret code Source code Key code None of these Machine code Question 3 2 pts What is the symbol that marks the beginning of a one line comment? Question 1 2 pts The preprocessor executes after the compiler. True False Question 5 2 pts A statement that may be used to stop...

  • instructions These questions should test if you have understood the contents of Chapter 18 "Recursion". 1....

    instructions These questions should test if you have understood the contents of Chapter 18 "Recursion". 1. What will this method return if you call it this: xMethod (4) static int xMethod (int n) { if (n == 1) return 1; else return n + xMethod (n - 1); } 1. 10 2. 11 3. 12 4. 9 2. Analyze the following code: public class Test { public static void main (String [] args) { int [] x = {1, 2,...

  • Question 2 - Programming Exercise 1. Make a directory for this lab and change into it....

    Question 2 - Programming Exercise 1. Make a directory for this lab and change into it. 2. Copy files using the following command: cp/net/data/ftp/pub/class/115/ftp/cpp/Inheritance/Exercise.cpp Exercise.cpp Finish the program so that it compiles and runs. The instructions are contained in the C++ file. Your completed program should generate output similar to the following: TwoD default constructor This program asks for the coordinates of two points in 3D space and calculates their distance. Please enter the xyz coordinates for the first point:...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT