Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem Statement: Part A Write a program that prompts the user for the following pieces of information concerning the raw materials the user has to

Problem Statement: Part A

Write a program that prompts the user for the following pieces of information concerning the raw materials the user has to make lemonade:

1) The number of lemons they have 2) The number of bags of sugar they have

Given this information, along with the three following constants you should define in your program,

static final int LEMONS_PER_PITCHER = 12;

static final int SPOONS_PER_BAG = 1000;

static final int SPOONS_PER_PITCHER = 50;

you should determine the maximum number of pitchers of lemonade that the user can make. Your answer should be a non-negative integer. Thus, even if there are leftover ingredients to create .3 of a pitcher, you should not count this at all. You may assume that the water is free and the lemonade only consists of water, lemons and sugar. (Note: Determine the meaning of the constants by looking at the sample data. Ask a TA if necessary.)

Input Specification

1. The number of lemons will be a non-negative integer.

2. The number of bags of sugar will be a non-negative integer.

Output Specification

Output the number of pitchers of lemonade the user can make. Your output should follow the format below, where X represents the number of pitchers:

You can make a maximum of X pitchers.

Output Samples

Here are three sample outputs of running the program. Note that this set of tests is NOT a comprensive test. You should test your program with different data than is shown here based on the specifications given. The user input is given in italics while the program output is in bold.

Output Sample #1

Enter the number of lemons you have

36

Enter the number of bags of sugar you have.

1

You can make a maximum of 3 pitchers.

Output Sample #2

Enter the number of lemons you have

400

Enter the number of bags of sugar you have.

1

You can make a maximum of 20 pitchers.

Output Sample #3

Enter the number of lemons you have

84

Enter the number of bags of sugar you have.

0

You can make a maximum of 0 pitchers.

(I have been working on this problem all day and still can't figure it out)

(underneath is my c code. i have been using virtual studios to run my code)

int main(void) { int LEMONS_PER_PITCHER = 12; int SPOONS_PER_BAG = 1000; int SPOONS_PER_PITCHER = 50; int lemons, bags; printf("Enter the number of lemons you have."); scanf_s("%d", &lemons);

printf("Enter the number of bags of sugar you have."); scanf_s("%d", &bags);

if (lemons<0)

{ printf("lemons must be greater than equal to zero"); } if (bags<0) { printf("bags must be greater than equal to zero"); } int pitchers = (lemons / LEMONS_PER_PITCHER + bags / SPOONS_PER_PITCHER) / SPOONS_PER_BAG;

printf("you can make a maximum of pitchers ", pitchers );

system("pause"); return 0;

( the output i get is)

Enter the number of lemons you have

36

Enter the number of bags of sugar you have.

1

You can make a maximum of pitchers.

(what am i missing in the code that it is not giving me the 3 pitchers)

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

SQL Server Query Performance Tuning

Authors: Sajal Dam, Grant Fritchey

4th Edition

1430267429, 9781430267423

More Books

Students also viewed these Databases questions