English 中文(简体)
Intro to C. 便携式罐头适当印刷
原标题:Intro to C / Variables aren t printing properly
  • 时间:2023-10-19 02:57:45
  •  标签:
  • c

该法典应当从用户那里获得有关家庭贷款细节的投入,并计算他们在贷款期间将支付多少费用。 我的《守则》适当吸收了所有投入,但以我“为”的回旋方式印刷这些投入。 我的“Month”变量被定在令人难以置信的高位,其余则定在0。 如何使我的守则适当发挥作用

我预计会拿到贷款余额的所有投入,从业者,每个月支付多少款项,以及年数。 然后,将计算为总余额和利息支付金额支付的款项,并在最后月份之前每个月印出,届时将支付全部款项和现余额。

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    int years, month, final_month, annual_interest_rate;
    
    double loan_balance, interest_for_this_month, monthly_payment, total_interest, leftover_payment, monthly_interest_rate;
    
    printf("

Loan Amount = ");
    scanf("%lf", &loan_balance);
    printf("%.2lf
", loan_balance);
    
    printf("

Number of Years = ");
    scanf("%i", &years);
    printf("%i
", years);
    
    printf("

Annual Interest Rate Percent = ");
    scanf("%i", &annual_interest_rate);
    printf("%i
", annual_interest_rate);
    
    printf("
Monthly Payment = ");
    scanf("%.2lf", &monthly_payment);
    printf("%.2lf
", monthly_payment);
    
    monthly_interest_rate = annual_interest_rate/1200;
    
    final_month = years*12;
    //total_interest = 0; 
    
    for(month = 1; month <= final_month; month = month+1)
    { 
        interest_for_this_month = (monthly_interest_rate * loan_balance);
        total_interest = (total_interest + interest_for_this_month);
        leftover_payment = (monthly_payment - interest_for_this_month);
        loan_balance = (loan_balance - leftover_payment);
        printf("Month = (%i),   This month s interest = (%.2lf)   leftover payment = (%.2lf)   Loan Balance = (%.2lf

)"); month, interest_for_this_month, leftover_payment, loan_balance;
        
    }
    
    printf("
Total Interest = %.2lf
", total_interest);
    printf("Final Loan Balance = %.2lf


", loan_balance);

    return 0;
}
问题回答

暂无回答




相关问题
Fastest method for running a binary search on a file in C?

For example, let s say I want to find a particular word or number in a file. The contents are in sorted order (obviously). Since I want to run a binary search on the file, it seems like a real waste ...

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

Tips for debugging a made-for-linux application on windows?

I m trying to find the source of a bug I have found in an open-source application. I have managed to get a build up and running on my Windows machine, but I m having trouble finding the spot in the ...

Trying to split by two delimiters and it doesn t work - C

I wrote below code to readin line by line from stdin ex. city=Boston;city=New York;city=Chicago and then split each line by ; delimiter and print each record. Then in yet another loop I try to ...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...

Encoding, decoding an integer to a char array

Please note that this is not homework and i did search before starting this new thread. I got Store an int in a char array? I was looking for an answer but didn t get any satisfactory answer in the ...

热门标签