#include <iostream.h>

main(){

int balance;
int payment;
int payment_num = 1;
int months = 0;
float interest;

cout << "Please input a value for the balance" << endl;
cin >> balance;

cout << "Please input a value for the payment" << endl;
cin >> payment;

while (balance > 0)
{
		if (balance <= 5000){
		interest = .13 * balance;
	}

		if (balance >= 5001 || <= 10000){
		interest = .18 * balance;
	}

		if (balance > 10000){
		interest = .21 * balance;
	}
	balance = balance + interest - payment;
	payment_num++;
	months++;
	cout << "After" << payment_num << "Payments your balance is:" << balance 

<< endl;
}

	cout << "It took you" << months << "to pay off your debt" <end;
}

Just I'm brand new to this community and I've been coding HTML/CSS for years. However, I'm taking a basic computer science class and I'm really struggling with C. I was instructed to create a program that will do the following:

You need to pay off credit card debt following a lengthy stay in college. You need to input a balance of what your loans total to and the payment amount you think you can make each month.

APR rates are
Balance APR
$1-$5000 13%
$5001-$10000 18%
> $10000 21%

In this assignment, you will write a program that will determine the number of months it will take you to pay off your debt.

New balance is equal to the previous balance plus the monthly interest minus the payment amount.

Output the payment number (payment_num) and the remaining balance after each payment until the debt is paid off. Use endl so that it will be easy to read on the screen. The output statement should be inside the while loop.

Output a statement showing the number of months it will take for you to pay off your debt.

I'm sure someone in this community can help me. I know this is really basic and pretty rude of me just to ask you guys to help me solve this, but I'm really struggling! (I also know I've made a TON of mistake as it's told me when I've tried to run the program....)

I appreciate any and all help! Thank you!

[boilerplate_help_info]

Posing requests for help must be well thought out if you want help quickly and correctly.  Your post did not meet the criteria for quality help. You may get some posts, but are they going to be useful?  Check your post with these checkpoints - what is it [i]you[/i] missed:
[list=1]
[*]Ask a question that can be answered. Do not ask
- What's wrong with my code?
- Why doesn't this work?
- Anything else that does not give us useful information
[*]Post your code.  If we don't know what you did, how can we possibly help?
- Use [b]PROPER FORMATTING[/b] -- see this
- Use CODE Tags so your formatting is preserved.
If we can't follow your code, it's difficult to help. We don't care that you're still working on it. If you want us to read it, it must be readable
[*]Explain what the code is supposed to do.  If we don't know where the target is, how can we help you hit it?
[*]Explain what actually happened! If we don't know where the arrow went when you shot it, how can we tell what went wrong and how far from the target you are?
[*]If you have errors, post them! We can't see your screen.  We can't read your mind. You need to tell us what happened.
[*]To [b]not[/b] ask for code. We are not a coding service. We will help you fix your code. 
    If anyone posts working code for you, they are a cheater. 
    If you use that code [i]you[/i] are a cheater.
[*]Do [b]not[/b] bore us with how new you are. We can tell by your code.
- Do not apologize. We were all new, and unless you are completely 
  brain dead you will get better.
- Do not ask us to "take it easy on you."
- Do not say "I don't know what's going on." That's obvious since
  you posted for help. Use that time wisely by [b]explaining[/b] as best 
  you can so we can help.
[*][b]Do not post your requirements and nothing else. [/b]We view that as a lazy do-nothing student that wants us to do their work for them. That's cheating and we [i]will[/i] be hard on you.
[*][b]Do not tell us how urgent it is.[/b] Seriously, for us there is no urgency at all. Many that can help will ignore any URGENT or ASAP requests.
[/list]
Think more about your next post so we don't have to play 20 questions to get the info we need to help you.

[/boilerplate_help_info]

Sorry about that. The only thing I did wrong I suppose is proclaim how new I was. I also forgot to post what actually happened when I tried to run the program.

Here's what it said.
ERROR: multiple operators together
ERROR: invalid operands for or operator ||
ERROR: syntax error before at line 25 in file 'C:\users\owner\desktops\lab11.ch
==> if (balance >= 5001 || <= 10000){
BUG: if (balance >= 5001 || <= 10000<== ???
ERROR: invalid operands for les than operator <
ERROR: argument 3 of the function is undefined or not a valid expression
ERROR: syntax error before or at line 38 in file 'C\users\owner\desktop\lab11.ch
==> _printf << "it took you" << months << "to pay off your debt" <end;
BUG: _printf << "it took you" << months << "to pay off your debt" <end;<==??
?
ERROR: cannot execute command 'C:\Users\owner\desktop\lab11.ch

Hopefully someone has some suggestions for me. I can't seem to figure out how to make the payments keep repeating thus drawing the balance to 0. Please look at my first post for more information. Thank you ahead of time for any and all help.

You need to look up the syntax for the IF statement. You have it incorrect for compound comparisons.

Alrighty, Other than that does the algorithm seem to make sense to you guys?

Looks OK so far.

[edit]

Sorry about that. The only thing I did wrong I suppose is proclaim how new I was. I also forgot to post what actually happened when I tried to run the program.

Proper formatting, too. But yours is better than most. :icon_wink:
[/edit]

Edited 5 Years Ago by WaltP: n/a

This article has been dead for over six months. Start a new discussion instead.