Can you help me help out a friend with his college programming assignment? Its already two days late. Lol.
Spoiler
COP 3223 - Programming Assignment #3
Assigned: 2/17/10 (Wednesday)
Due: 3/15/10 (Monday) at 11:55 PM WebCourses time
Objectives
1. Practice using loops.
2. Learn how to read data from an input text file.
3. Learn how to use an array to store data and solve problems that require the storage and manipulation of that data.
Problem A: Inheritance
Your long-lost uncle has left you a certain sum of money in his will. Since you’re an organized planning type, you’d like to figure out how long this money will last you, under the assumption that you use a certain amount of it each year. In addition, the money will be in an account that accrues interest yearly. Your job will be to write a program that can make calculations for you showing you how much money will be left in the inheritance account after each year.
In particular, here is the order in which things occur:
1) Interest accrues for the year.
2) You withdraw money at the end of the year.
Your job will be to print a chart of how much money is taken out (all years will be the same except for the last) and how much money is left.
The user will prompted for and input the following values:
1) Amount of the inheritance
2) Amount he/she will use each year
3) Interest rate on the account (entered as a percentage)
Input Specification
1. The inheritance will be a positive integer in between 10,000 and 1,000,000.
2. The amount used will be a positive integer greater than 1,000 and less than the inheritance amount. It will also be strictly greater than the amount of interest the account accrues during the first year.
3. The interest rate will be a real number in between 1 and 10, representing the annual interest rate on the account as a percentage.
Output Specification
Output chart with the following format:
Year Payment Money Left
---- ------- ----------
1 XX.XX YY.YY
2 XX.XX YY.YY
…
N XX.XX 0.00
where XX.XX is the payment you receive from the inheritance each year and YY.YY is the money left after the payment has been disbursed. The last line of the chart must have 0.00 as the amount of money left. N represents the number of years the payments last.
Sample Run (User input in italics, program output in bold)
How much is your inheritance, in dollars?
10000
How much of it will you spend each year, in dollars?
1500
What is the interest rate of the inheritance account?
10
Year Payment Money Left
---- ------- ----------
1 1500.00 9500.00
2 1500.00 8950.00
3 1500.00 8345.00
4 1500.00 7679.50
5 1500.00 6947.45
6 1500.00 6142.20
7 1500.00 5256.41
8 1500.00 4282.06
9 1500.00 3210.26
10 1500.00 2031.29
11 1500.00 734.42
12 807.86 0.00
Problem B: Golf Outing
You are an avid golfer, but keeping score tends to make your golf outings less enjoyable. You have finally decided that if you write a program that keeps score once, then you won’t ever have to worry about mentally keeping tabs on the game.
The goal of golf is to strike a ball until it drops into a hole in the ground. The fewer times you need to hit the ball to achieve the goal, the better. A game of golf has 18 holes, and on each hole, a particular score (usually 3, 4 or 5) is designated as “par”. A particular player’s score for a hole is simply the number of times they need to hit the golf ball from the starting position to get it into the hole.
Your program will read in information about a single golf course that several players have played from a file called golf.txt. Your job will be to output everyone’s final score.
To calculate a final score in a game of golf, you simply calculate your score (the sum of the number of strokes it took to get the ball in the hole for all 18 holes) and subtract from it the sum of the par scores for each hole. For example, if the total number of strokes you took was 70 and the sum of all the par scores was 72, then your score would be 70 – 72 = -2.
Input Specification
1. The first line of the input file will contain a single positive integer, n (n < 100), specifying the number of people playing on the golf course.
2. The next line will contain 18 integers all separated by spaces representing the par score for each of the holes, from hole 1 to hole 18.
3. The following n lines will contain the 18 values each (positive integers in between 1 and 20, inclusive), representing the scores for a single golfer on each hole. The first of these lines represents the scores of golfer #1. The second of these lines represents the scores of golfer #2, etc.
Output Specification
For each of the n golfers, output a line with the following format:
Golfer #k’s score: X.
where k represents the golfer number (starting at 1) and X represents his/her score. (X may be negative as shown in the example.)
Sample Input File (golf.txt)
2
3 4 4 4 4 5 5 3 3 4 4 4 4 4 5 3 3 4
4 4 5 4 6 4 5 6 3 4 4 4 5 4 3 3 5 4
2 3 4 4 4 5 5 3 3 4 4 4 4 4 4 3 3 4
Sample Output (Corresponding to Sample Input File)
Golfer #1’s score: 7.
Golfer #2’s score: -3.
Problem C: Golf Outing Revisited
All of your friends are excited about your new golf program. Everyone is now having more fun when they play because they don’t have to keep score. Unfortunately, some of your friends want more feedback than your current program is giving them. They want to know their score, hole by hole.
The input to your program will be exactly the same as your old program (also from golf.txt), but your output will be more detailed. Here is the new output specification:
For each of the n golfers, output a line with the following format:
Golfer #k’s score: A B C D E F G H I J K L M N O P Q R
where k represents the golfer number (starting at 1) and each letter represents their score on each hole. (A for hole 1, B for hole 2, etc.)
Using the same input file as shown in part B, the following shows the sample output for this part:
Sample Output (Corresponding to Sample Input File)
Golfer #1’s score: 1 0 1 0 2 -1 0 3 0 0 0 0 1 0 -2 0 2 0
Golfer #2’s score: -1 -1 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0
Deliverables
You must submit the source code (The .c files, not the .exe files) for your programs over WebCourses by 11:55 PM by Monday, March 15th, 2010. Each program should be in its own file and named appropriately to convey which part of the assignment it is. You must send your source files as an attachment using the "Add Attachments" button. Assignments that are e-mailed or typed into the submission box will not be accepted.
Restrictions
Your programs must compile and run using Dev-C++. It’s okay to develop your program using the IDE of your choice, but make sure that it will compile under Dev-C++. Each of your programs 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 programs will be graded upon the following criteria:
1) 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 with Dev C++ (in Windows). If your program does not compile in this environment, you will get a sizable deduction from your grade.
Assigned: 2/17/10 (Wednesday)
Due: 3/15/10 (Monday) at 11:55 PM WebCourses time
Objectives
1. Practice using loops.
2. Learn how to read data from an input text file.
3. Learn how to use an array to store data and solve problems that require the storage and manipulation of that data.
Problem A: Inheritance
Your long-lost uncle has left you a certain sum of money in his will. Since you’re an organized planning type, you’d like to figure out how long this money will last you, under the assumption that you use a certain amount of it each year. In addition, the money will be in an account that accrues interest yearly. Your job will be to write a program that can make calculations for you showing you how much money will be left in the inheritance account after each year.
In particular, here is the order in which things occur:
1) Interest accrues for the year.
2) You withdraw money at the end of the year.
Your job will be to print a chart of how much money is taken out (all years will be the same except for the last) and how much money is left.
The user will prompted for and input the following values:
1) Amount of the inheritance
2) Amount he/she will use each year
3) Interest rate on the account (entered as a percentage)
Input Specification
1. The inheritance will be a positive integer in between 10,000 and 1,000,000.
2. The amount used will be a positive integer greater than 1,000 and less than the inheritance amount. It will also be strictly greater than the amount of interest the account accrues during the first year.
3. The interest rate will be a real number in between 1 and 10, representing the annual interest rate on the account as a percentage.
Output Specification
Output chart with the following format:
Year Payment Money Left
---- ------- ----------
1 XX.XX YY.YY
2 XX.XX YY.YY
…
N XX.XX 0.00
where XX.XX is the payment you receive from the inheritance each year and YY.YY is the money left after the payment has been disbursed. The last line of the chart must have 0.00 as the amount of money left. N represents the number of years the payments last.
Sample Run (User input in italics, program output in bold)
How much is your inheritance, in dollars?
10000
How much of it will you spend each year, in dollars?
1500
What is the interest rate of the inheritance account?
10
Year Payment Money Left
---- ------- ----------
1 1500.00 9500.00
2 1500.00 8950.00
3 1500.00 8345.00
4 1500.00 7679.50
5 1500.00 6947.45
6 1500.00 6142.20
7 1500.00 5256.41
8 1500.00 4282.06
9 1500.00 3210.26
10 1500.00 2031.29
11 1500.00 734.42
12 807.86 0.00
Problem B: Golf Outing
You are an avid golfer, but keeping score tends to make your golf outings less enjoyable. You have finally decided that if you write a program that keeps score once, then you won’t ever have to worry about mentally keeping tabs on the game.
The goal of golf is to strike a ball until it drops into a hole in the ground. The fewer times you need to hit the ball to achieve the goal, the better. A game of golf has 18 holes, and on each hole, a particular score (usually 3, 4 or 5) is designated as “par”. A particular player’s score for a hole is simply the number of times they need to hit the golf ball from the starting position to get it into the hole.
Your program will read in information about a single golf course that several players have played from a file called golf.txt. Your job will be to output everyone’s final score.
To calculate a final score in a game of golf, you simply calculate your score (the sum of the number of strokes it took to get the ball in the hole for all 18 holes) and subtract from it the sum of the par scores for each hole. For example, if the total number of strokes you took was 70 and the sum of all the par scores was 72, then your score would be 70 – 72 = -2.
Input Specification
1. The first line of the input file will contain a single positive integer, n (n < 100), specifying the number of people playing on the golf course.
2. The next line will contain 18 integers all separated by spaces representing the par score for each of the holes, from hole 1 to hole 18.
3. The following n lines will contain the 18 values each (positive integers in between 1 and 20, inclusive), representing the scores for a single golfer on each hole. The first of these lines represents the scores of golfer #1. The second of these lines represents the scores of golfer #2, etc.
Output Specification
For each of the n golfers, output a line with the following format:
Golfer #k’s score: X.
where k represents the golfer number (starting at 1) and X represents his/her score. (X may be negative as shown in the example.)
Sample Input File (golf.txt)
2
3 4 4 4 4 5 5 3 3 4 4 4 4 4 5 3 3 4
4 4 5 4 6 4 5 6 3 4 4 4 5 4 3 3 5 4
2 3 4 4 4 5 5 3 3 4 4 4 4 4 4 3 3 4
Sample Output (Corresponding to Sample Input File)
Golfer #1’s score: 7.
Golfer #2’s score: -3.
Problem C: Golf Outing Revisited
All of your friends are excited about your new golf program. Everyone is now having more fun when they play because they don’t have to keep score. Unfortunately, some of your friends want more feedback than your current program is giving them. They want to know their score, hole by hole.
The input to your program will be exactly the same as your old program (also from golf.txt), but your output will be more detailed. Here is the new output specification:
For each of the n golfers, output a line with the following format:
Golfer #k’s score: A B C D E F G H I J K L M N O P Q R
where k represents the golfer number (starting at 1) and each letter represents their score on each hole. (A for hole 1, B for hole 2, etc.)
Using the same input file as shown in part B, the following shows the sample output for this part:
Sample Output (Corresponding to Sample Input File)
Golfer #1’s score: 1 0 1 0 2 -1 0 3 0 0 0 0 1 0 -2 0 2 0
Golfer #2’s score: -1 -1 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0
Deliverables
You must submit the source code (The .c files, not the .exe files) for your programs over WebCourses by 11:55 PM by Monday, March 15th, 2010. Each program should be in its own file and named appropriately to convey which part of the assignment it is. You must send your source files as an attachment using the "Add Attachments" button. Assignments that are e-mailed or typed into the submission box will not be accepted.
Restrictions
Your programs must compile and run using Dev-C++. It’s okay to develop your program using the IDE of your choice, but make sure that it will compile under Dev-C++. Each of your programs 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 programs will be graded upon the following criteria:
1) 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 with Dev C++ (in Windows). If your program does not compile in this environment, you will get a sizable deduction from your grade.