Question
In this project you will create a console C++ program that will have the user to enter Celsius temperature readings for anywhere between 1 and
In this project you will create a console C++ program that will have the user to enter Celsius temperature readings for anywhere between 1 and 365 days and store them in a dynamically allocated array, then display a report showing both the Celsius and Fahrenheit temperatures for each day entered. This program will require the use of pointers and dynamic memory allocation.
Getting and Storing User Input: For this you will ask the user how many days worth of temperature readings they wish to enter. This value must be numeric and between 1 and 365. Do not forget to check for non-numeric input.
Array allocation: Once you have determined how many temperature readings to store, allocate the appropriate amount of memory to a pointer using the new[] operator. This should happen in a try {} block. If the memory allocation fails at run-time, the new[] operator throws a bad_alloc exception. Include a catch{} block that displays the error message Error allocating memory to the user if this happens. Remember that all memory allocated with the new[] operator should be freed when you are done with it. The final statement of your try block should delete[] your pointer.
Getting valid temperature readings: The temperatures the user enters should fall between the range -90.0C and +60.0C. Do not accept an input value outside of that range.
Processing: Converting Celsius to Fahrenheit To generate the required output, you will need to convert each Celsius temperature to Fahrenheit. Given this is a fairly generic task that could be re-used in another program, you should create a function to do this. The actual calculation is straight forward; the function body may only need to be one line of code, so the function should be inline. Keep in mind that a processing function should only do processing, not input or output. Pass the Celsius temperature in as a parameter and send the Fahrenheit temperature back using a return statement.
Output: This Weeks Temperature Report Use an Output Function: Write a function that will display the temperatures entered in Celsius and Fahrenheit formatted as above. You must pass this function a pointer to the array storing the Celsius temperatures and the number of items in that array and you are required to use pointer arithmetic to move from one index of the array to the next. You may not use the array subscript operator in this function. Formatting Hints: Look up the ASCII code value for the degrees symbol. Each column of the report is right aligned ten characters wide.
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