Question
The number of plants purchased at a store is related to the number of available plants and the temperature outdoors. The relationship of outdoor temperature
The number of plants purchased at a store is related to the number of available plants and the temperature outdoors. The relationship of outdoor temperature to sales is:
outdoor Temperature | percent of plants sold |
colder than 40 degrees, i.e. temp < 40 | 10% |
Between 40 degrees and 60 degrees. i.e. 40 <=temp < 60 | 30% |
Between 60 degrees and 70 degrees. i.e. 60 <= temp <70 | 50% |
Between 70 Degrees and 80 degrees. i.e, 70 <= temp < 80 | 60% |
Hotter than or equal to 80 degrees i.e, temp >= 80 | 40% |
Write a program in C++ that will read the input from the file (in.txt) for the number of available in the store and then the outdoor temperature for the week. Your program will calculate the estimated number of plants which will be sold in a week (7 days) using the user input.
Sample input | Sample output |
100 40 89 62 32 42 53 66 | Estimated total sale is 96 plants |
Explanation for the above output:
on the first day, the store had 100 available plants to sale.
Temperature on Day 1 is 40 deg => 30% sold => 70 available plants for the next day.
Temperature on DAy 2 is 89 deg => 40 % sole => 42 available plants for the next day
Temperatue on Day 3 is 62 deg => 50 % sold => 21 available plants for the next day.
Temperature on Day 4 is 32 deg => 10% sold => 19 available plants for the next day.
Temperature on Day 5 is 42 deg => 30% sold => 13 available plants for the next day
Temperature on Day 6 is 53 deg => 30% sold => 9 available plants for the next day.
Temperature on Day 7 is 66 deg => 50% sold => 4 available plants for the next day.
Therefore, it is estimated that 96 plants to be sold this week.
Approximated sold plant is an integer value, so, use round() function from cmath library to find the approximated sold plants. One sample input file( in. txt) has been attached with the assignment.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started