#include <iostream>
#include "C++_A4_MIN.h"
//writer 5396952 Hyeonmin LEE
// using namespace std; is less problematic in an cpp file, as it is restricted to only this file
// I still prefer to write std::cout and such, it is more readable and at least you are sure you use the functions from the right library
// Here another way to do it: using on the single components you want to use (a bit like in Java)
using std::cin;
using std::cout;
using std::endl;
int main(int argc, char** argv) {
int num = 0;
// you have to use double values here, or you wont be able to read decimals number with std::cin
double bal = 0;
double chrg = 0;
double credit = 0;
double creditLimit = 0;
// you don"t need the "class" keyword before the class name
// BONUS: you don't need the "struct" keyword either when declaring a struct in C++ (in C you need it so it is a bit confusing :x)
Account account;
while (true) {
std::cout << "Enter customer number. (or -1 to end)" << std::endl;
std::cin >> num;
// we check if we could read the customer number correctly
if (std::cin.fail()) {
// couldn't read? then f*ck it! we simply quit the program!
// if you wanted you could the user again for his input, but in that case you have to first clean the buffer of std::cin (reset what is currently in std::cin in short)
// if we don't do this than if we ask for a number again, it is just gonna fail again!
return 1;
}
// now we have a valid num (and we are sure it is set!)
if (num == -1) {
return 0;
}
account.setNum(num);
// once cout with std::cout
std::cout << "Enter beginning balance." << std::endl;
std::cin >> bal;
account.setBal(bal);
std::cout << "Enter total charge." << std::endl;
std::cin >> chrg;
account.setChrg(chrg);
// once simply cout (as we have done using std::cout we can do this)
cout << "Enter total credits." << endl;
cin >> credit;
account.setCredit(credit);
cout << "Enter credit limit." << endl;
cin >> creditLimit;
account.setCreditLimit(creditLimit);
account.getExceed();
}
return 0;
}
//Sante pour genius friendo Sascha!
#include "C++_A4_MIN.h"
//writer 5396952 Hyeonmin LEE
// using namespace std; is less problematic in an cpp file, as it is restricted to only this file
// I still prefer to write std::cout and such, it is more readable and at least you are sure you use the functions from the right library
// Here another way to do it: using on the single components you want to use (a bit like in Java)
using std::cin;
using std::cout;
using std::endl;
int main(int argc, char** argv) {
int num = 0;
// you have to use double values here, or you wont be able to read decimals number with std::cin
double bal = 0;
double chrg = 0;
double credit = 0;
double creditLimit = 0;
// you don"t need the "class" keyword before the class name
// BONUS: you don't need the "struct" keyword either when declaring a struct in C++ (in C you need it so it is a bit confusing :x)
Account account;
while (true) {
std::cout << "Enter customer number. (or -1 to end)" << std::endl;
std::cin >> num;
// we check if we could read the customer number correctly
if (std::cin.fail()) {
// couldn't read? then f*ck it! we simply quit the program!
// if you wanted you could the user again for his input, but in that case you have to first clean the buffer of std::cin (reset what is currently in std::cin in short)
// if we don't do this than if we ask for a number again, it is just gonna fail again!
return 1;
}
// now we have a valid num (and we are sure it is set!)
if (num == -1) {
return 0;
}
account.setNum(num);
// once cout with std::cout
std::cout << "Enter beginning balance." << std::endl;
std::cin >> bal;
account.setBal(bal);
std::cout << "Enter total charge." << std::endl;
std::cin >> chrg;
account.setChrg(chrg);
// once simply cout (as we have done using std::cout we can do this)
cout << "Enter total credits." << endl;
cin >> credit;
account.setCredit(credit);
cout << "Enter credit limit." << endl;
cin >> creditLimit;
account.setCreditLimit(creditLimit);
account.getExceed();
}
return 0;
}
//Sante pour genius friendo Sascha!
댓글
댓글 쓰기