Starting from:

$25

COP 3223 Introduction to C Assignment 4

This assignment is worth a maximum of 100 points Objectives: The purpose of this assignment, is for students to demonstrate knowledge of • the basic template of a simple C program • correct syntax of the while and for loops • semantics of while and for loops in C • how to declare appropriate variable types to store program data • how to use simple C syntax and semantics to create a program that compiles and runs correctly  use of comments to annotate code Problem: Your Aunt was diagnosed with Diabetes 6 months ago. It was enough to motivate her to begin a serious exercise regimen. She has been tracking her progress in a text file-weightlog.txt. She began by storing her goal weight and the number of weeks that she has been on task. Then each week she stores her weight on Monday and Friday. The problem with her data tracking technique is that useful analysis or summary data cannot be obtained simply and quickly. Your mum has just volunteered your services to put your computer magic to work, to prepare a program that will make summarizing the file data painless and quick. After a little chat with your Aunt, you have discovered she would like to be able to summarize the data in her text log, at any point in her journey. When the program is run, she would like a progress report. The report should contain the following information: 1. The goal weight in pounds 2. The total weight lost in pounds 3. The maximum weight lost in a week in pounds 4. The minimum weight lost in a week in pounds 5. The average weight lost per week in pounds 6. A check to see if the goal weight has been met. If yes, the week when it was reached 7. How much weight still has to be lost to reach the goal The progress report should be formatted as shown in the sample code run. Submission of Assignment Your assignment should be submitted via Webcourses by the deadline. No assignments will be accepted via email. Your submission should include a single .c file called progressReport.c . Remember that your program will be graded using DevC++ , so be sure that your submitted code runs correctly in this IDE. If you do not have DevC++ on your personal machine, you may use a computer in any lab to test your code. Restrictions: Please ensure that your program output matches the output in the sample run. Naturally, the numeric values will be different, depending on the data in the input file used. However, the text of the output should be the same. The code constructs used in the assignment solution should include only material covered in class up to day of submission. For example you are not to use arrays. You may assume that: • The input file weightlog.txt exists. • Weight is logged in pounds as a number with 1 decimal place. • The file data is terminated by the number 0 Input File Format: Goal Weight n (Number of weekly entries) Week1 start weight week1 end weight : : Weekn start weight weekn end weight 0 Below is sample input and output that would be produced when your program is run. Sample run of progressReport.c Weightlog.txt 135 5 158.2 157.5 157.0 156.5 156.6 151.2 151.0 148.9 148.7 146.4 0 Program Output Progress Report After 5 weeks ---------------------------------------- Goal Weight: 135 lbs Total Weight Lost: 11.0 lbs Min lost in a week: 0.5 lbs Max lost in a week: 5.4 lbs Avg weight lost per week: 2.2 lb Weight Goal is not met yet Weight still to be lost: 11.4 lbs

More products