Question

Write a program that asks the user to enter the types of dark chocolate and the...

Write a program that asks the user to enter the types of dark chocolate and the number of packages purchased at the SHSU@ACM freshly made store. Make sure that you display the following chart for the user to make the selection. The plain base chocolate cost $5.00. The flavor and sweetness can be added to add on various rate.

Chocolate Intensity Percentage                   Flavor & Sweetness              Cost Rate

            1 - 25%                                               Super Sweet                            10%

26 - 50%                                             Strong Sweet                           15%

51 – 75%                                             Mild Sweet                             20%

76 – 95%                                             Minimum Sweet                     25%

*Note: If there are more than 6 package purchased, apply 25 percent for the total bill.

Your program needs to compute the sale amount (before adding tax) and the tax amount on a bill. The tax should be 8.25 percent of the total charge. Write a program that display the chocolate base charge per package of 3.5 oz, prompts the user to enter the chosen Flavor & Sweetness, number of chocolate that the customer wants to buy, then display the number of chocolate ordered, total base charge, additional cost, tax, and the total cost of the order.

Here is the sample as an output:

Chocolate Intensity Percentage                   Flavor & Sweetness              Cost Rate

            1 - 25%                                               Super Sweet                            10%

26 - 50%                                             Strong Sweet                           15%

51 – 75%                                             Mild Sweet                             20%

76 – 95%                                             Minimum Sweet                     25%

Chocolate Base Charge: $5.00

Flavor & Sweetness: Super Sweet

The number of chocolate ordered: 2

Base Charge: $10.0

Additional Cost: $1.0

Tax: $0.91

The total cost: $11.91

The language is java. Thank you

0 0
Add a comment Improve this question Transcribed image text
Answer #1


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


class Choco
{
   public static void main (String[] args) throws java.lang.Exception
   {
   System.out.println("WELCOME TO SHSU@ACM freshly made store!!!!");
   Scanner sc= new Scanner(System.in);
     
   System.out.println("");
   System.out.println("HERE IS OUR CHART ");
  

//PRINT THE MENU


       System.out.println("Chocolate Intensity Percentage \t\t Flavor & Sweetness \t\t Cost Rate ");
   System.out.println(" 1 - 25% \t\t Super Sweet \t\t 10%");
   System.out.println(" 26 - 50% \t\t Strong Sweet \t\t 15%");
   System.out.println(" 51 - 75% \t\t Mild Sweet \t\t 20%");
   System.out.println(" 76 - 95% \t\t Minimum Sweet \t\t 25% ");
   System.out.println("");

//TAKE USER INPUT
   System.out.println("PLEASE ENTER THE CHOICE OF YOUR FLAVOUR & SWEETNESS ");
String chocolate= sc.nextLine();
   System.out.println("PLEASE ENTER NUMBER OF PACKAGES YOU NEED ");
  int pack= sc.nextInt();
     
System.out.println("");
     
     
   double cost_rate=0.0;
     
   String chocolate1= new String("Super Sweet");
     
   String chocolate2= new String("Strong Sweet");
     
   String chocolate3= new String("Mild Sweet");
     
     
   String chocolate4= new String("Minimum Sweet");
     
     
//CHECKING USER INPUT TO CALCULATE COST RATE   
   if(chocolate.equalsIgnoreCase(chocolate1))
   {
   cost_rate=0.10;
     
   }
   else if(chocolate.equalsIgnoreCase(chocolate2))
   {
   cost_rate=0.15;
   }
   if(chocolate.equalsIgnoreCase(chocolate3))
   {
   cost_rate=0.20;
   }
     
   if(chocolate.equalsIgnoreCase(chocolate4))
   {
   cost_rate=0.25;
   }
     
//PRINTING MENU
     
   System.out.println("Chocolate Base Charge: $5.00");
   System.out.println("Flavor & Sweetness:"+chocolate);
   System.out.println("The number of chocolate ordered:" +pack);

//IF PACKAGE IS MORE THAN 6 apply 25 percent for the total bill.
   if(pack>6)
   {
   double discount=0.25;
   double base_charge= 5* pack;
   System.out.println("Base Charge: $"+base_charge);
   double additional_cost= cost_rate*base_charge;
   System.out.println("Additional Cost: $"+additional_cost);
   double total_charge= base_charge+ additional_cost;
   double total_charge2= total_charge-(0.25*total_charge);
  
   double tax= 0.0825* total_charge;
   double tax2 = Math.round(tax * 100D) / 100D;
   System.out.println("Tax: $"+tax2);
   double final_cost= total_charge +tax2;
  
   System.out.println("The total cost: $"+final_cost);
  
     
   }

//IF PACKAGE IS LESS THAN 6
   else{
  
     double base_charge= 5* pack;
  
     
   System.out.println("Base Charge: $"+base_charge);
   double additional_cost= cost_rate*base_charge;
   System.out.println("Additional Cost: $"+additional_cost);
   double total_charge= base_charge+ additional_cost;
  
   double tax= 0.0825* total_charge;
   double tax2 = Math.round(tax * 100D) / 100D;
   System.out.println("Tax: $"+tax2);
   double final_cost= total_charge +tax2;
   System.out.println("The total cost: $"+final_cost);
  
   }
  
   }
  
}

Add a comment
Know the answer?
Add Answer to:
Write a program that asks the user to enter the types of dark chocolate and the...
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
  • Write a program that asks the user to enter a string and then asks the user...

    Write a program that asks the user to enter a string and then asks the user to enter a character. The program should count and display the number of times that the specified character appears in the string. python programming

  • Write a java program that asks the user to enter an integer. The program should then...

    Write a java program that asks the user to enter an integer. The program should then print all squares less than the number entered by the user. For example, if the user enters 120, the program should display 0, 1, 4, 9, 16, 25, 36, 49, 64, 81, and 100.

  • Write a program that asks the user to enter a number ofseconds.• There are...

    Starting Out with C++ (9th Edition)  Chapter 4, Problem 7PCWrite a program that asks the user to enter a number of seconds.• There are 86400 seconds in a day. If the number of seconds entered by the user is greater than or equal to 86400, the program should display the number of days in that many seconds.• There are 3600 seconds in an hour. If the number of seconds entered by the user is less than 86400, but is greater...

  • You are to write a program IN C++ that asks the user to enter an item's...

    You are to write a program IN C++ that asks the user to enter an item's wholesale cost and its markup percentage. It should then display the item's retail price. For example: if the an item's wholesale cost is 5.00 and its markup percentage is 100%, then the item's retail price is 10.00 If an item's wholesale cost is 5.00 and its markup percentage is 50%, then the item's retail price is 7.50 Program design specs. You should have 5...

  • 1. Markup Write a program that asks the user to enter an item's wholesale cost and...

    1. Markup Write a program that asks the user to enter an item's wholesale cost and its markup percentage. It should then display the item's retail price. For example: . If an item's wholesale cost is $5.00 and its markup percentage is 100 percent, then . If an item's wholesale cost is $5.00 and its markup percentage is 50 percent, then The program should have a function named calculateReta1l that receives the wholesale the item's retail price is $10.00. the...

  • Price Markup Write a program that asks the user to enter an item’s wholesale cost and...

    Price Markup Write a program that asks the user to enter an item’s wholesale cost and its markup percentage. It should then display the item’s retail price. For example: If an item’s wholesale cost is 5.00 and its markup percentage is 100%, then the item’s retail price is 10.00. If an item’s wholesale cost is 5.00 and its markup percentage is 50%, then the item’s retail price is 7.50. The program should have a function named calculateRetail that receives the...

  • PLEASE WRITE IN 80X86 ASSEMBLY LANGUAGE Write a program that asks the user to enter their...

    PLEASE WRITE IN 80X86 ASSEMBLY LANGUAGE Write a program that asks the user to enter their monthly costs for each of the following housing-related expenses: rent or mortgage payment utilities phones cable The program should then display the total monthly cost of these expenses and the total annual cost of these expenses.

  • Write a Python program that asks the user to enter the number of calories and fat...

    Write a Python program that asks the user to enter the number of calories and fat grams in a food item. The program should display the percentage of the calories that come from fat. One gram of fat has 9 calories, therefore: Calories from fat = fat grams * 9 The percentage of calories from fat can be calculated as follows: Calories from fat / total calories If the calories from fat are less than 30 percent of the total...

  • ***** JAVA ONLY ***** Write a program that asks the user to enter the name of...

    ***** JAVA ONLY ***** Write a program that asks the user to enter the name of a file, and then asks the user to enter a character. The program should count and display the number of times that the specified character appears in the file. Use Notepad to create a simple file that can be used to test the program. ***** JAVA ONLY *****

  • Design a program that asks the user to enter a series of 20 numbers. The program...

    Design a program that asks the user to enter a series of 20 numbers. The program should store the numbers in the array and then display the following data: The lowest number in the array The highest number in the array The total of the number in the array The average of the numbers in the array PLEASE GIVE THE PSEUDOCODE AND CODE IN C PROGRAMMING

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
ADVERTISEMENT