我正在尝试为我的c ++类编写一个程序,我无法让循环工作正常而且我迷失了如何获取日期。任何帮助,将不胜感激。 好的,所以我继续并更新程序,它完全“工作”,但它没有正确对齐,当我试图定义我的名字,它不工作,不知道那是什么。我主要需要协助将值与列对齐,并且日期被填充为01而不是1
#include <iostream>
using namespace std;
#include <iomanip>
#include <stdlib.h>
#defin studen name
int main()
{
int ACCT, MM, DD, YYYY, PYMNM;
double FEE, DWN, Tot, PYM;
system("cls");
cout<< "Dr.Thad Zalfolkz service fee's\n";
cout<< "This program will ask you for your \n";
cout<< "account number, consultation date\n";
cout<< "treatment fee, and the initial payment.\n";
cout<< "Then calculate a payment plan.\n\n";
cout<<"Please input your account number: ";
cin>> ACCT;
while (ACCT>9999||ACCT<0){
cout<< "\nError, input a valid account number.\n";
cin>> ACCT;
}
cout<< "Please input the consultation date with a space between each. (MM DD YYYY)";
cin>> MM;
cin>> DD;
cin>> YYYY;
cout<<"Please input your treatment fee: $";
cin>> FEE;
while (FEE<0){
cout<< "\nPlear input a valid fee.\n";
cin>> FEE;
}
cout<<"Please input your initial payment: ";
cin>> DWN;
while (DWN<0){
cout<< "\nPlear input a valid value.\n";
cin>> DWN;
}
cout<<"Please input your desired monthly payment: ";
cin>> PYM;
cout<<"\n\n\n";
while (PYM<=0){
cout<< "\nPlear input a valid value.\n";
cin>> PYM;
}
cout<< "Patient account number:" << ACCT<<endl;
cout<< "Consultation Date:";
cout<< MM;
cout<<"/";
cout<<DD;
cout<< "/";
cout<<YYYY<<endl;
cout<< "Treatment Fee $"<<FEE <<endl;
cout<< "Initial Payment $"<<DWN <<endl;
cout<< "Balance $"<<FEE-DWN <<endl<<endl;
cout<< "Payment Due Payment Total Outstanding \n";
cout<< "Number Date Amount Paid Balance \n";
FEE=FEE-DWN;
Tot=DWN;
PYMNM=0;
while(FEE>0){
if (FEE<=PYM){ PYM=FEE;}
if (MM=12){
MM=1;
YYYY+1;
}
MM+1;
++PYMNM;
FEE=FEE-PYM;
Tot=Tot+PYM;
cout<< PYMNM;
cout<<" ";
cout<< MM;
cout<<"/";
cout<< DD ;
cout<< "/";
cout<< YYYY;
cout<<" ";
cout<< PYM;
cout<<" ";
cout<< Tot;
cout<<" ";
cout<< FEE;
cout<<" \n";
}
cout<<"=========================Payment schedule printed by: =============================";
}
答案 0 :(得分:1)
检查你的布尔逻辑。 ACCT&GT; 9999&安培;&安培; ACCT℃,
是否可能是ACCT同时大于9999且小于0?
的情况用OR(||)替换AND(&amp;&amp;)。