I need to write a program that takes in two values entered by the user, compares them with 50 and 5000, chooses the max and min of these values and takes them as initial deposits. It works out the compound interest at 5% on 15,000 in monthly instalments and shows the interest for each initial deposit for 2 years and 10 years. I need to include fill characters and field separators but none of it seems to be working for me. any mistakes found would be a great help. (its a rough draft so is very messy)
In this expression: if (ans == 'N' && ans == 'n')//condition if user answers no to question
It is impossible that ans can be both 'N' and 'n' which would be the requirement in order that the expression will ever be true.
This: while (ans == 'Y' || ans == 'y' && initialdeposit<=max);
makes more sense. Take a look at the operator precedence:
&& is higher than ||. Hence the expression is like this: (ans == 'Y') || ((ans == 'y') && (initialdeposit<=max))
You see the problem? Better use parenthesis.