Dear Reddtee
I would like to make some observations about your code. So far I have not studied it in detail so I am not proposing that these observations will solve the problem. However they are errors that need to be addressed.
In your printf() statements you start of with varied amounts of ?%s?. These indicate that after the double quotes you are going to print a string. These identifies of strings are not present. Indeed you have no reason for identifiers to be present. If you remove them, you should also remove the commas that are separating the lines of text to be printed. If you do not
remove the commas only the last line prints. If my memory serves me: commas are a Visual Basic way of linking strings of text that you code over several lines. Your code would then be more usual. I cannot say with certainty that they are affecting the code.
I compiled your code and got three warnings. In three of your case statements you have entered.
getchar();
ch = getchar();
if (ch == 'n' || ch == 'N')
break;
The warnings say that the first of these lines has not effect. I remarked out (put /* in front of and */ at end of, to make the code unread) these lines and the three warnings stopped. I cannot say with certainty that this will solve the problem.
I ran the programme and tried the q option to quit. Having pressed q and then return it did not quit. I then pressed a key not listed on screen and the programme quit.
It might be worth pursuing this a little first. Many coders prefer to get the structure (moving between screens and functions) right first as this ensures that they are dealing correctly with data that may remain in the buffer. There are many input options and your compiler will tell you about each one and give you information about how they work. Some are : getc, getch,
getchar, getche, scanf(%c, identifier). I think that some retain characters in the buffer and some do not.
I concluded this partially because I ran the programme again and chose the P option. After entering the three numerical inputs the screen displayed the monthly payments and the choice of continuing. It did not wait for an answer and went through the P option again. I was stuck in a perpetual loop.
Was this your experience as well ?
Assuming it was then consider using ? fflush(stdin); ? in a strategic place to eliminate this problem.
I realise that I have not attempted to answer the maths question. My first observation here is that you have declared the identifiers ?principal?, ?rate? and ?duration? as doubles. However when you are scanning them in you have used the format specifier for a float (f). It is likely that they never go into the identifiers. Please try ?lf?. Also when printing out.
Good luck with whatever route you chose.
Stephanos