Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is part 2 of the previous code ; I just need the code so please disregard the reflection part Part-2 (40%) Instructions In a

This is part 2 of the previous code ; I just need the code so please disregard the reflection part

image text in transcribedimage text in transcribedimage text in transcribed

Part-2 (40%) Instructions In a new source code file "w3p2.c", upgrade the solution to Part-1 to include data input for a specified number of days that records the user's self-diagnosed "wellness rating for the morning and evening periods of each day. The application will end with a summary of statistics about the data entered. 1. Review the "Part-2 Output Example" (next section) to see how the program is expected to work 2. Add another macro to define the maximum days (3) of data to collect from the user: #define LOG_DAYS 3 Note: This program must be coded in such a manner that it will work no matter what value is set for LOG_DAYS, 3 - 300 - 3000 - or more 3. Continuing from Part-1, use a for iteration construct to loop the necessary number times based on the defined LOG_DAYS Note: _You will need to create additional variables. Be sure to place them at the beginning of the main function so all variables are organized and grouped together and in one place 4. Nest inside the for construct, the following: a) Display the current log date in the format: YYYY-MMM-DD as described in Part-1 Note: The day value must be derived from a variable and not hard-coded, and remember the log always begins on the 1st day of the month b) For each day, you need to read two (2) double floating-point user input values that represent a morning and an evening self-diagnosis rating value c) Display a prompt to get the user input value for the "morning" diagnosis. This is a value that should be between 1.0 and 5.0 inclusive (refer to the example output) d) Validate the rating value entered by the user. An incorrect value that is out of range, should display the appropriate error message and prompt again for a value and repeat as many times as is necessary until a valid value is entered e) Repeat the same logic from step: c) above only for the "evening" diagnosis. f) Repeat from step #4 until the number of desired days is reached 5. After all the data is entered by the user, a summary should be displayed consisting of the following: The sum of all the valid values entered for the morning ratings The sum of all the valid values entered for the evening ratings The sum of all the valid values entered for the combined morning and evening ratings o Note: Display all sums to 3-decimal precision points The average morning rating based on the number of LOG_DAYS of data entered The average evening rating based on the number of LOG_DAYS of data entered . . . . The average combined morning and evening rating based on the number of LOG_DAYS of data entered o Note: Display all averages to 1-decimal precision point Part-2 Output Example (Note: Use this data for submission) General Well-being Log Set the year and month for the well-being log (YYYY MM): 2009 1 ERROR: The year must be between 2010 and 2021 inclusive Set the year and month for the well-being log (YYYY MM): 2022 1 ERROR: The year must be between 2010 and 2021 inclusive Set the year and month for the well-being log (YYYY MM): 2021 O ERROR: Jan. (1) - Dec. (12) Set the year and month for the well-being log (YYYY MM): 2021 13 ERROR: Jan.(1) - Dec. (12) Set the year and month for the well-being log (YYYY MM): 2009 ERROR: The year must be between 2010 and 2021 inclusive ERROR: Jan.(1) - Dec. (12) Set the year and month for the well-being log (YYYY MM): 2022 13 ERROR: The year must be between 2010 and 2021 inclusive ERROR: Jan.(1) - Dec. (12) Set the year and month for the well-being log (YYYY MM): 2021 2 *** Log date set! *** 2021-FEB-01 Morning rating (0.0-5.0): -0.9 ERROR: Rating must be between 0.0 and 5.0 inclusive! Morning rating (0.0-5.0): 5.01 ERROR: Rating must be between 0.0 and 5.0 inclusive! Morning rating (0.0-5.0): 4.25 Evening rating (0.0-5.0): -0.9 ERROR: Rating must be between 0.0 and 5.0 inclusive! Evening rating (0.0-5.0): 5.01 ERROR: Rating must be between 0.0 and 5.0 inclusive! Evening rating (0.0-5.0): 5 2021-FEB-2 Morning rating (0.0-5.0): 0 Evening rating (0.0-5.0): 4.9 2021-FEB-03 Morning rating (0.0-5.0): 5 Evening rating (0.0-5.0): 6 Summary ==EEEE Morning total rating: 9.250 Evening total rating: 9.900 Overall total rating: 19.150 Average morning rating: 3.1 Average evening rating: 3.3 Average overall rating: 3.2 Reflection (50%) Instructions Create a text file named "reflect.txt" Record your answers in the reflect.txt file for each of the following: 1. Mapping the month integer value to the first three characters of the month name could have been accomplished using one of two possible selection constructs. What are they, and provide a short example of how each would be written in C to display the first two months? 2. The logic applied to validate the values entered by the user required iteration. What are the 3 types of iteration constructs? What one did you use for the validation routines, and briefly explain why? 3. Describe what you did to test and debug your program. How did you go about finding where the problems were located? Academic Integrity It is a violation of academic policy to copy content from the course notes or any other published source (including websites, work from another student, or sharing your work with others). Failure to adhere to this policy will result in the filing of a violation report to the Academic Integrity Committee. Part-2 Submission 1. Upload your source file "w3p2.d" to your matrix account 2. Upload your reflection file "reflect.txt" to your matrix account (to the same directory) 3. Login to matrix in an SSH terminal and change directory to where you placed your workshop source code. 4. Manually compile and run your program to make sure everything works properly: gcc -Wall w3p2.c -owl If there are no error/warnings are generated, execute it: w3 5. Run the submission command below (replace profname.proflastname with your professors Seneca userid and replace NAA with your section): -profName.proflastname / submit 144w3/NAA_p2 6. Follow the on-screen submission instructions Part-2 (40%) Instructions In a new source code file "w3p2.c", upgrade the solution to Part-1 to include data input for a specified number of days that records the user's self-diagnosed "wellness rating for the morning and evening periods of each day. The application will end with a summary of statistics about the data entered. 1. Review the "Part-2 Output Example" (next section) to see how the program is expected to work 2. Add another macro to define the maximum days (3) of data to collect from the user: #define LOG_DAYS 3 Note: This program must be coded in such a manner that it will work no matter what value is set for LOG_DAYS, 3 - 300 - 3000 - or more 3. Continuing from Part-1, use a for iteration construct to loop the necessary number times based on the defined LOG_DAYS Note: _You will need to create additional variables. Be sure to place them at the beginning of the main function so all variables are organized and grouped together and in one place 4. Nest inside the for construct, the following: a) Display the current log date in the format: YYYY-MMM-DD as described in Part-1 Note: The day value must be derived from a variable and not hard-coded, and remember the log always begins on the 1st day of the month b) For each day, you need to read two (2) double floating-point user input values that represent a morning and an evening self-diagnosis rating value c) Display a prompt to get the user input value for the "morning" diagnosis. This is a value that should be between 1.0 and 5.0 inclusive (refer to the example output) d) Validate the rating value entered by the user. An incorrect value that is out of range, should display the appropriate error message and prompt again for a value and repeat as many times as is necessary until a valid value is entered e) Repeat the same logic from step: c) above only for the "evening" diagnosis. f) Repeat from step #4 until the number of desired days is reached 5. After all the data is entered by the user, a summary should be displayed consisting of the following: The sum of all the valid values entered for the morning ratings The sum of all the valid values entered for the evening ratings The sum of all the valid values entered for the combined morning and evening ratings o Note: Display all sums to 3-decimal precision points The average morning rating based on the number of LOG_DAYS of data entered The average evening rating based on the number of LOG_DAYS of data entered . . . . The average combined morning and evening rating based on the number of LOG_DAYS of data entered o Note: Display all averages to 1-decimal precision point Part-2 Output Example (Note: Use this data for submission) General Well-being Log Set the year and month for the well-being log (YYYY MM): 2009 1 ERROR: The year must be between 2010 and 2021 inclusive Set the year and month for the well-being log (YYYY MM): 2022 1 ERROR: The year must be between 2010 and 2021 inclusive Set the year and month for the well-being log (YYYY MM): 2021 O ERROR: Jan. (1) - Dec. (12) Set the year and month for the well-being log (YYYY MM): 2021 13 ERROR: Jan.(1) - Dec. (12) Set the year and month for the well-being log (YYYY MM): 2009 ERROR: The year must be between 2010 and 2021 inclusive ERROR: Jan.(1) - Dec. (12) Set the year and month for the well-being log (YYYY MM): 2022 13 ERROR: The year must be between 2010 and 2021 inclusive ERROR: Jan.(1) - Dec. (12) Set the year and month for the well-being log (YYYY MM): 2021 2 *** Log date set! *** 2021-FEB-01 Morning rating (0.0-5.0): -0.9 ERROR: Rating must be between 0.0 and 5.0 inclusive! Morning rating (0.0-5.0): 5.01 ERROR: Rating must be between 0.0 and 5.0 inclusive! Morning rating (0.0-5.0): 4.25 Evening rating (0.0-5.0): -0.9 ERROR: Rating must be between 0.0 and 5.0 inclusive! Evening rating (0.0-5.0): 5.01 ERROR: Rating must be between 0.0 and 5.0 inclusive! Evening rating (0.0-5.0): 5 2021-FEB-2 Morning rating (0.0-5.0): 0 Evening rating (0.0-5.0): 4.9 2021-FEB-03 Morning rating (0.0-5.0): 5 Evening rating (0.0-5.0): 6 Summary ==EEEE Morning total rating: 9.250 Evening total rating: 9.900 Overall total rating: 19.150 Average morning rating: 3.1 Average evening rating: 3.3 Average overall rating: 3.2 Reflection (50%) Instructions Create a text file named "reflect.txt" Record your answers in the reflect.txt file for each of the following: 1. Mapping the month integer value to the first three characters of the month name could have been accomplished using one of two possible selection constructs. What are they, and provide a short example of how each would be written in C to display the first two months? 2. The logic applied to validate the values entered by the user required iteration. What are the 3 types of iteration constructs? What one did you use for the validation routines, and briefly explain why? 3. Describe what you did to test and debug your program. How did you go about finding where the problems were located? Academic Integrity It is a violation of academic policy to copy content from the course notes or any other published source (including websites, work from another student, or sharing your work with others). Failure to adhere to this policy will result in the filing of a violation report to the Academic Integrity Committee. Part-2 Submission 1. Upload your source file "w3p2.d" to your matrix account 2. Upload your reflection file "reflect.txt" to your matrix account (to the same directory) 3. Login to matrix in an SSH terminal and change directory to where you placed your workshop source code. 4. Manually compile and run your program to make sure everything works properly: gcc -Wall w3p2.c -owl If there are no error/warnings are generated, execute it: w3 5. Run the submission command below (replace profname.proflastname with your professors Seneca userid and replace NAA with your section): -profName.proflastname / submit 144w3/NAA_p2 6. Follow the on-screen submission instructions

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

Students also viewed these Databases questions