#include <iostream>
using namespace std;
class Customer{
private :
int cstNum; // cst = customer
int cstBal;//balance
int cstChrg;//charge
int cstCredit;
int cstCreditLimit;
public :
Customer(){//consturctor
cstNum = 0;
cstBal = 0;
cstChrg = 0;
cstCredit = 0;
cstCreditLimit = 0;
}
void setNum(int num){
cstNum = num;
}
void setBal(double bal){
cstBal = (int)bal * 100;
}
void setChrg(double chrg){
cstChrg = (int)chrg * 100;
}
void setCredit(double credit){
cstCredit = (int)credit * 100;
}
void setCreditLimit(double creditLimit){
cstCreditLimit = (int)creditLimit * 100;
}
double getNewBalance(){
return ((double)cstBal - (double)cstCredit + (double)cstChrg) * 0.01;
}
void getExceed(){
double newBalance = getNewBalance();
double creditLimit = cstCreditLimit / 100.0; //explicit transform
if(creditLimit < cstCreditLimit){
std::cout << "new balance is" << newBalance << ", " << cstNum << "'s credit limit is exceed" << std::endl;
}
else{
std::cout << "new balance is" << newBalance << ". " <<endl;
}
}
};
using namespace std;
class Customer{
private :
int cstNum; // cst = customer
int cstBal;//balance
int cstChrg;//charge
int cstCredit;
int cstCreditLimit;
public :
Customer(){//consturctor
cstNum = 0;
cstBal = 0;
cstChrg = 0;
cstCredit = 0;
cstCreditLimit = 0;
}
void setNum(int num){
cstNum = num;
}
void setBal(double bal){
cstBal = (int)bal * 100;
}
void setChrg(double chrg){
cstChrg = (int)chrg * 100;
}
void setCredit(double credit){
cstCredit = (int)credit * 100;
}
void setCreditLimit(double creditLimit){
cstCreditLimit = (int)creditLimit * 100;
}
double getNewBalance(){
return ((double)cstBal - (double)cstCredit + (double)cstChrg) * 0.01;
}
void getExceed(){
double newBalance = getNewBalance();
double creditLimit = cstCreditLimit / 100.0; //explicit transform
if(creditLimit < cstCreditLimit){
std::cout << "new balance is" << newBalance << ", " << cstNum << "'s credit limit is exceed" << std::endl;
}
else{
std::cout << "new balance is" << newBalance << ". " <<endl;
}
}
};
댓글
댓글 쓰기