Please Help with C++

I'm taking an online class in computer science, it has been so easy until we started with C++ (and no, there's no dropping the class, its past that date or else I would). I need major help, I have no idea what I am doing and absolutely NO background in programming at all. I've studied the screencasts the professor sent out, I've ask my professor for help but he just can't explain it simply enough. If someone could show me how this is supposed to look, and WHY it looks like that. I want to understand why it looks that way so I can complete the rest of the semester's assignments.

Anyway, this is our assignment this week:

Lab:

The semester is fast approaching its end and you are preparing for graduation. You are very excited about the new job you have landed but this also means that it is time to pay off your credit card debt. Your credit card has an adjustable interest rate which depends on the remaining balance (debt). The table below shows the annual interest rates for your credit card based on the balance.

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.

• Declare two integer variables called balance and payment. Balance represents the dollar amount of your debt and payment represents the amount you think you can pay every month. Note that by making the balance and payment variables of type integer, we can only input/output whole dollar amounts (no cents, e.g. 90 but not 90.01).

• For each of the variables balance and payment, output a phrase asking the user to input a value for the variable followed by an input statement.

• Declare an integer variable called payment_num. Assign the numeric value 1 to the variable payment_num.

• Develop an algorithm to determine how many months it will take to pay off your debt. Convert the algorithm to Ch code. Note that you will need to use a while loop to make the monthly calculations. The new balance after each payment is equal to the previous balance plus the accumulated monthly interest minus the payment amount. Think about how the accumulated monthly interest should be computed. Be sure to use the correct APR when computing the new balance. Hint: You will need a nested if statement inside the while loop to select the correct APR.

• 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.

• Save your program as lab10.ch Test and debug your program. Your program will not look exactly like anyone else’s.




And this is what I have so far:

/* Lab */
#include <isostream.h>
main ( )
{
int balance;
int payment;
int months =0;
cout <<"What is your balance?" <<endl;
cin >> balance;
cout <<"What is your payment?" <<endl;
cin >> payment;
int payment_num = 1;
while (payment > balance)
{
if (APR==.13){
1-5000
}
else{
(APR==.18){
5001-10000
}
else{
(APR==.21){
>10000
}
cout <<"Enter balance you owe"<<endl;
cin >>balance;
cout >>"Enter your payment amount"<<endl;
cin >>payment;
new balance = (balance + APR) - payment;
Firstly, the header file should not have the .h
1
2
3
4
5
6
7
8
#include <iostream>
using std::cout;
using std::endl;
using std::cin;

// To be lazy you can use
using namespace std; 
// But this is frowned upon in professional development 


Next, your main method should be defined properly
1
2
3
int main() {
 return 0; // 0 = success
}


Next you want to write in English what your application has to do in stages
1
2
3
4
5
6
7
8
int balance = 10000;
int payment = 100;
int payment_num = 1;

// while balance is greater than 0 
 // add interest to balance
 // take off payment from balance
 // increment payment_num by 1 

Then convert the English (pseudo-code) to C++
Topic archived. No new replies allowed.