| CIS 330 Home Page | Last updated 2008/01/07 13:03:25 |
Each of the following programs should be coded in a single source file. Your solution must work as described in the problem statement. It is also important that your code be readable and well written. You will lose points on the problem if your logic is too convoluted or your code is unnecessarily complex. Coding style is also an important factor in the grading and don't forget to comment your code appropriately.
3 6 9 12 15 18 21 24 27 30
33 36 39 42 45 48 51 54 57 60
63 66 69 72 75 78 81 84 87 90
93 96 99 102 105 108 111 114 117 120
123 126 129 132 135 138 141 144 147 150
// A number in hexadecimal is given on command line
int main(int argc, char *argv[]) {
if (argc > 1) {
int num = hexStringToInt(argv[1]);
cout << "In decimal, " << argv[1] << " is " << num << endl;
}
return 0;
}
P * r * (1 + r)n / ( (1 + r)n - 1)The amount of a monthly payment that would be interest would be the monthly interest rate times the remaining loan amount. The rest would go toward paying down the loan balance.
Remember there is no exponential operator in C/C++, just as in Java. You can use the pow method of the math library. To use this library, #include math.h in your code, and add the option -lm at the end of the compile command. To convert string arguments to numbers, you can use atof and atoi, or scanf, or iostream operators.
Output should be formatted as shown in this example. You can use printf or iostream operators for formatting.
% payment 1000 6 12 Monthly payment for a $1000.00 6.00% loan of 12 monthly payments is $86.07 Payment Interest Principal Balance 1 $5.00 $81.07 $918.93 2 $4.59 $81.47 $837.46 3 $4.19 $81.88 $755.58 4 $3.78 $82.29 $673.29 5 $3.37 $82.70 $590.59 6 $2.95 $83.11 $507.48 7 $2.54 $83.53 $423.95 8 $2.12 $83.95 $340.01 9 $1.70 $84.37 $255.64 10 $1.28 $84.79 $170.85 11 $0.85 $85.21 $85.64 12 $0.43 $85.64 $-0.00
should appear on output unchanged.const char *begcmt = "/*";