这是我第一次来这里,我在编写程序时遇到了问题。我正在尝试获得每月付款和返还工资,根据工资和汽车付款的大小使用不同的打印报表。但是,我的输出没有正确输出。我收到 .2f 作为输出变量,而不是我想要的变量。有谁知道可能出了什么问题?
#include <stdio.h>
#include <math.h>
int main() {
float cost;
float interest;
int years;
float salary;
float sal_twenty;
float payment;
float IM;
float NumMon;
printf("Enter annual income > ");
scanf("%f", &salary);
printf("Enter cost of car > ");
scanf("%f", &cost);
printf("Enter annual interest rate > ");
scanf("%f", &interest);
printf("Enter duration of loan in years > ");
scanf("%d", &years);
sal_twenty = salary * .2;
IM = interest/12;
NumMon=years*12;
payment = cost * (IM * pow((IM + 1), NumMon))/(pow((IM + 1), NumMon) - 1);
if (payment*12 > sal_twenty) {
printf("A monthly payment of ");
printf(".2f", payment);
printf(" is too high given your annual income of ");
printf(".2f", &salary);
}
if (payment*12 <= sal_twenty) {
printf("Your annual income of ");
printf(".2f", salary);
printf(" allows a monthly payment of ");
printf(".2f", payment);
}
return 0;
}