Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Meadowdale Dairy Farm sells organic brown eggs to local customers. They charge $3.25 for a dozen eggs, or 45 cents for individual eggs that are

Meadowdale Dairy Farm sells organic brown eggs to local customers. They charge $3.25 for a dozen eggs, or 45 cents for individual eggs that are not part of a dozen. Write a class that prompts a user for the number of eggs in the order and then display the amount owed with a full explanation. For example: "You ordered 27 eggs. That's 2 dozen at $3.25 per dozen and 3 loose eggs at 45 cents each for a total of $7.85." Save the class as Eggs.java.

Make sure your code has the following:

(Code must run in Eclipse IDE Java Developer 17.0.1)

  • Be sure to include valid double data type CONSTANTS for both prices; do not define as integers
  • Receive number of eggs needed as an integer (use nextInt() from Scanner class)
  • Be sure your calculations work with any (integer) number of eggs the user enters
  • Perform necessary calculations
  • Perform any data type conversions required to print properly, in the correct format
  • Use printf() to print the output
  • Calculations are not performed in a print line. Perform calculations, save results in variables, print the variables from the print lines.

image text in transcribed

Expected Output (3 separate runs) Enter number of eggs needed >> 15 You ordered 15 eggs. That's 1 dozen at $3.25 per dozen and 3 loose eggs at 45 cents each for a total of $4.60. Enter number of eggs needed >> 38 You ordered 38 eggs. That's 3 dozen at $3.25 per dozen and 2 loose eggs at 45 cents each for a total of $10.65. Enter number of eggs needed >> 7 You ordered 7 eggs. That's a dozen at $3.25 per dozen and 7 loose eggs at 45 cents each for a total of $3.15

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

AWS Certified Database Study Guide Specialty DBS-C01 Exam

Authors: Matheus Arrais, Rene Martinez Bravet, Leonardo Ciccone, Angie Nobre Cocharero, Erika Kurauchi, Hugo Rozestraten

1st Edition

1119778956, 978-1119778950

More Books

Students also viewed these Databases questions

Question

1. Where do these biases come from?

Answered: 1 week ago

Question

7. What decisions would you make as the city manager?

Answered: 1 week ago