Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program in java that will determine if a given shopper is “a savvy shopp

ID: 3724530 • Letter: W

Question

Write a program in java that will determine if a given shopper is “a savvy shopper” or not. “A savvy shopper” is someone whose average cost per item is less than $10.00.If a given shopper’s average cost per item is greater than or equal to $10.00 they do not get any special comments. You will prompt the user for input using either Scanner or JOptionPane, whichever you prefer. Use a constant (declare a double along with the keyword final) to store the value 10.00. Comments are required for this assignment. Inputs: • Number of items • Total amount paid Outputs: • Average cost per item • If and only if they are “a savvy shopper”, output “You are a savvy shopper!” • Output an appropriate “Thank you” message of your choice

Explanation / Answer

import java.util.*;

class Ideone
{
public static void main (String[] args)
{
  Scanner input = new Scanner(System.in);
  
   final double savvyCost = 10;//final constant
  
  //input number of items and total amount paid
   System.out.println("Enter the number of items : ");
   int items = input.nextInt();
   System.out.println(" Enter the total amount paid : ");
   double amount = input.nextDouble();
  
   double avgCost = amount/items;//compute average cost
  
   if(avgCost < savvyCost)
   {
   System.out.println(" You are a savvy shopper!");
  
   System.out.println(" Thank you !!!");
   }
  
}
}

Output:

Enter the number of items :56

Enter the total amount paid : 789

Enter the number of items :43

Enter the total amount paid :390

You are a savvy shopper!

Thank you !!!

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote