Objectives
1. Review use of if statements and loops.
2. Learn how to write functions given specifications.
3. Learn how to use pass by reference variables.
4. Learn how to put together a useful program given a skeleton of that program and the
functions and their specifications necessary in the implementation.
Problem: Lemonade Stand
Last summer your friend has a lemonade stand and made lots of money. You want to do the same! You have plenty of time to plan, so you thought you would be pre
pared when summer came around by writing a program to simulate your lemonade stand. The basic idea behind the simulation is as follows:
1) You will simulate 10 days of running the lemonade stand.
2) In the beginning the user gets a $20.00 loan to run the lemonade stand.
3) Before each day, the user gets an opportunity to buy bags of lemons and sugar.
4) At the beginning of each day the user receive a weather report.
5) Based on that, the user is asked to price a cup of lemonade for that day.
6) Then, the days sales are simulated. (Part of this is written for you.)
7) Afterwards, the user is prompted with a status report of how much money they have left and how many bags of lemons and sugar they have left.
What you have to do
A skeleton of the solution for this assignment is posted on WebCourses and the course web page. Please use this skeleton. You must fill in the seven functions that are left for you to fill in, as well as write the remainder of main so the program works as described above. After you write each function, you should test it before moving on. How to do this will be covered in class. Then, write your main, calling the necessary functions from it to achieve the desired functionality. main can work without declaring any new variables than the ones already declared. But, you may declare new ones if you wish.
Perhaps the biggest problem you will have will be not knowing when to make function calls. The goal of having these functions is to make the coding process more manageable. In particular, it is possible that a function might “do” something complicated, but that just really means that function makes calls to other functions that carry out a majority of that work already. In essence, if you write a function A to do a task, then don’t write out the code that also does that task in another function B. Instead call the function A from the body of function B.
References
Textbook: Chapters 9, 10, 11 Notes: Lectures 13, 14, 15, 17
Output Sample
Two full output samples of the program running will be provided on Webcourses and the course web page in the files lemonade.out and lemonade2.out.
Deliverables
You must submit your solution to the problem, lemonade.c, over WebCourses.
Restrictions
Although you may use other compilers, your program must compile and run using DevC++. Please use DevC++ to develop your program. Your program should include a header comment with the following information: your name, course number, section number, assignment title, and date. Also, make sure you include ample comments throughout your code describing the major steps in solving the problem.
Grading Details
Your program will be graded upon the following criteria:
1) Your correctness
2) Your programming style and use of white space. (Even if you have a plan and your program works perfectly, if your programming style is poor or your use of white space is poor you could get 10% or 15% deducted from your grade.)
3) Compatibility to DevC++. (If your program does not compile in this environment, you will get a sizable deduction from your grade, likely to be over 50%)
it has to be in pure c and i have a sample run of how the program should look when it runs and i have also included the skeleton of the program. thanks
Welcome to the Game of Lemonade!
You start the game with $20.00 and no supplies!
This is Day #1 for your Lemonade Stand.
Would you like to buy lemons?(Yes=1,No=0)
1
How many bags of lemons do you want to buy?
1
Would you like to buy sugar?(Yes=1,No=0)
1
How many bags of sugar do you want to buy?
1
Here is today’s weather forecast:
It is partly cloudy and windy.
How many cents will you sell a cup of lemonade for today?
30
You sold 15 cups of lemonade today.
Status report for day 1:
————————-
Cash Left: $19.00
Bags of Lemons Left: 0.55
Bags of Sugar Left: 0.40
This is Day #2 for your Lemonade Stand.
Would you like to buy lemons?(Yes=1,No=0)
1
How many bags of lemons do you want to buy?
1
Would you like to buy sugar?(Yes=1,No=0)
1
How many bags of sugar do you want to buy?
1
Here is today’s weather forecast:
It is cloudy with a high chance of rain.
How many cents will you sell a cup of lemonade for today?
25
You sold 8 cups of lemonade today.
Status report for day 2:
————————-
Cash Left: $15.50
Bags of Lemons Left: 1.31
Bags of Sugar Left: 1.08
This is Day #3 for your Lemonade Stand.
Would you like to buy lemons?(Yes=1,No=0)
0
Would you like to buy sugar?(Yes=1,No=0)
0
Here is today’s weather forecast:
It is cloudy with a high chance of rain.
How many cents will you sell a cup of lemonade for today?
40
You sold 9 cups of lemonade today.
Status report for day 3:
————————-
Cash Left: $19.10
Bags of Lemons Left: 1.04
Bags of Sugar Left: 0.72
This is Day #4 for your Lemonade Stand.
Would you like to buy lemons?(Yes=1,No=0)
1
How many bags of lemons do you want to buy?
1
Would you like to buy sugar?(Yes=1,No=0)
1
How many bags of sugar do you want to buy?
1
Here is today’s weather forecast:
It is partly cloudy and windy.
How many cents will you sell a cup of lemonade for today?
30
You sold 2 cups of lemonade today.
Status report for day 4:
————————-
Cash Left: $14.20
Bags of Lemons Left: 1.98
Bags of Sugar Left: 1.64
This is Day #5 for your Lemonade Stand.
Would you like to buy lemons?(Yes=1,No=0)
0
Would you like to buy sugar?(Yes=1,No=0)
1
How many bags of sugar do you want to buy?
1
Here is today’s weather forecast:
It is warm and sunny with medium winds.
How many cents will you sell a cup of lemonade for today?
40
You sold 2 cups of lemonade today.
Status report for day 5:
————————-
Cash Left: $13.00
Bags of Lemons Left: 1.92
Bags of Sugar Left: 2.56
This is Day #6 for your Lemonade Stand.
Would you like to buy lemons?(Yes=1,No=0)
1
How many bags of lemons do you want to buy?
1
Would you like to buy sugar?(Yes=1,No=0)
0
Here is today’s weather forecast:
It is cloudy with a high chance of rain.
How many cents will you sell a cup of lemonade for today?
35
You sold 10 cups of lemonade today.
Status report for day 6:
————————-
Cash Left: $13.00
Bags of Lemons Left: 2.62
Bags of Sugar Left: 2.16
This is Day #7 for your Lemonade Stand.
Would you like to buy lemons?(Yes=1,No=0)
0
Would you like to buy sugar?(Yes=1,No=0)
0
Here is today’s weather forecast:
It’s a perfect beach day. Sunny and hot!
How many cents will you sell a cup of lemonade for today?
40
You sold 44 cups of lemonade today.
Status report for day 7:
————————-
Cash Left: $30.60
Bags of Lemons Left: 1.30
Bags of Sugar Left: 0.40
This is Day #8 for your Lemonade Stand.
Would you like to buy lemons?(Yes=1,No=0)
0
Would you like to buy sugar?(Yes=1,No=0)
0
Here is today’s weather forecast:
It is partly sunny with low humidity.
How many cents will you sell a cup of lemonade for today?
20
You sold 9 cups of lemonade today.
Status report for day 8:
————————-
Cash Left: $32.40
Bags of Lemons Left: 1.03
Bags of Sugar Left: 0.04
This is Day #9 for your Lemonade Stand.
Would you like to buy lemons?(Yes=1,No=0)
1
How many bags of lemons do you want to buy?
1
Would you like to buy sugar?(Yes=1,No=0)
1
How many bags of sugar do you want to buy?
1
Here is today’s weather forecast:
It is warm and sunny with medium winds.
How many cents will you sell a cup of lemonade for today?
25
You sold 25 cups of lemonade today.
Status report for day 9:
————————-
Cash Left: $33.15
Bags of Lemons Left: 1.28
Bags of Sugar Left: 0.04
This is Day #10 for your Lemonade Stand.
Would you like to buy lemons?(Yes=1,No=0)
0
Would you like to buy sugar?(Yes=1,No=0)
0
Here is today’s weather forecast:
It is partly cloudy and windy.
How many cents will you sell a cup of lemonade for today?
35
You sold 0 cups of lemonade today.
Status report for day 10:
————————-
Cash Left: $33.15
Bags of Lemons Left: 1.28
Bags of Sugar Left: 0.04
You made a profit of $13.15 on your Lemonade Stand!