Question

In: Computer Science

A wholesale egg company bases their prices on the number of eggs purchased: 0 up to...

A wholesale egg company bases their prices on the number of eggs purchased: 0 up to but not including 4 dozen $0.50 per dozen 4 up to but not including 6 dozen $0.45 per dozen 6 up to but not including 11 dozen $0.40 per dozen 11 or more dozen $0.35 per dozen Extra eggs are priced at 1/12the per dozen price. Create an Eggs application that prompts the user for the number of eggs, and then calculates the bill. The application output should look similar to:

Enter the number of eggs purchased: 18

The bill is equal to: $0.75

Notes:

Coded in Java please.

Don't use any keyboard codes or anything too complicated. Try and make it the easiest way to solve it because I am in grade 11

Solutions

Expert Solution

Code:

import java.util.Scanner;/*Importing scanner class*/
class egg
{
   public static void main(String[] args)
   {
       int negg;
       double dozen,price;/*Declaring variables*/
       Scanner scnr=new Scanner(System.in);
       System.out.print("Enter the number of eggs purchased: ");
       negg=scnr.nextInt();/*no of eggs from the user*/
       dozen=negg/12.0;/*Calculating no of dozens*/
       if(dozen<4)
       {
           price=0.5;/*If no dozens is less than 4*/
       }  
       else if(dozen<6)
       {
           price=0.45;/*If no dozens is less than 6 and above 4 */
       }
       else if(dozen<11)
       {
           price=0.4;/*If no dozens is less than 11 and above 6 */
       }
       else
       {
           price=0.35;/*If no fo dozens 11 or above*/
       }
       System.out.print("The bill is equal to: $"+(dozen*price));
       /*Finally we print the bill*/
   }
}

Output:

Indentation:


Related Solutions

A container of one dozen large eggs was purchased at a local grocery store. Each egg...
A container of one dozen large eggs was purchased at a local grocery store. Each egg was measured to determine its diameter (in millimeters) and weight (in grams). The results for the 12 eggs are given in the following table. Weight is the dependent variable. Calculate the r-sqr, correlation coefficient, and explain each value. Index   1          2          3          4          5          6          7          8          9          10        11        12 Diameter (mm)            42.2     45.45   47.8     47.4     47.7     43.5     44.4     43.9     46.2     45.9     44.3    ...
The owner of Britten's Egg Farm wants to estimate the mean number of eggs laid per...
The owner of Britten's Egg Farm wants to estimate the mean number of eggs laid per chicken. A sample of 16 chickens shows they laid an average of 18 eggs per month with a standard deviation of 5 eggs per month.   a-2. What is the best estimate of this value? ANS ________ For a 90% confidence interval, what is the value of t? (Round the final answer to 3 decimal places.) The value of t is______    d. Develop the...
The owner of Britten's Egg Farm wants to estimate the mean number of eggs laid per...
The owner of Britten's Egg Farm wants to estimate the mean number of eggs laid per chicken. A sample of 30 chickens shows they laid an average of 25 eggs per month with a standard deviation of 12 eggs per month.   a-2. What is the best estimate of this value? c. For a 80% confidence interval, what is the value of t? (Round the final answer to 3 decimal places.) The value of t is  .    d. Develop the 80%...
An Egg producer wants to estimate the mean number of eggs produced per chicken.  A sample of...
An Egg producer wants to estimate the mean number of eggs produced per chicken.  A sample of 16 chickens shows they produced an average of 21 eggs per month with a standard deviation of 1.7 eggs per month. a. Develop a 99% confidence interval for the population mean b. What is the best estimate of the population mean? c. What distribution would you use for this analysis?
The owner of Britten's Egg Farm wants to estimate the mean number of eggs laid per...
The owner of Britten's Egg Farm wants to estimate the mean number of eggs laid per chicken. A sample of 34 chickens shows they laid an average of 27 eggs per month with a standard deviation of 14 eggs per month.   a-1. What is the value of the population mean? (Click to select)  It is unknown.  27.00  14 a-2. What is the best estimate of this value? b-1. Explain why we need to use the t distribution. (Click to select)  Use the t distribution...
An Egg producer wants to estimate the mean number of eggs produced per chicken.  A sample of...
An Egg producer wants to estimate the mean number of eggs produced per chicken.  A sample of 16 chickens shows they produced an average of 21 eggs per month with a standard deviation of 1.7 eggs per month. Develope a 99% confidence interval for the population mean a. [19.27,22.73] b. [20.25,21.75] c. [19.75,22.25] d. [20.09,21.91] 2) An Egg producer wants to estimate the mean number of eggs produced per chicken.  A sample of 16 chickens shows they produced an average of 21...
The owner of Britten's Egg Farm wants to estimate the mean number of eggs laid per...
The owner of Britten's Egg Farm wants to estimate the mean number of eggs laid per chicken. A sample of 20 chickens shows they laid an average of 21 eggs per month with a sample standard deviation of 2.99 eggs per month. (a-1) What is the value of the population mean?    (Click to select)21, 2.99, or It is unknown.    (a-2) What is the best estimate of this value?    (c) For a 99 percent confidence interval, the value...
The owner of Britten's Egg Farm wants to estimate the mean number of eggs laid per...
The owner of Britten's Egg Farm wants to estimate the mean number of eggs laid per chicken. A sample of 20 chickens shows they laid an average of 20 eggs per month with a standard deviation of 2 eggs per month. Develop the 95% confidence interval for the population mean. Would it be reasonable to conclude that the population mean is 21 eggs? What about 25 eggs?
The owner of Britten's Egg Farm wants to estimate the mean number of eggs laid per...
The owner of Britten's Egg Farm wants to estimate the mean number of eggs laid per chicken. A sample of 20 chickens shows they laid an average of 19 eggs per month with a sample standard deviation of 2.91 eggs per month. (a-1) What is the value of the population mean?    (Click to select)2.9119It is unknown.    (a-2) What is the best estimate of this value?    (c) For a 95 percent confidence interval, the value of t is...
You go out to the barn and start up the egg collecting machine. Eggs slide down...
You go out to the barn and start up the egg collecting machine. Eggs slide down a 30 degree ramp with a coefficient of kinetic friction of 0.2. What is the acceleration of the egg as it moves down the ramp? If the ramp is two meters long, how fast are the eggs moving when they hit the bottom? If we assume that the eggs are spherical with a radius of 3 cm, mass 200 grams and roll down the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT