Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <iomanip>
- using namespace std;
- int main() {
- string name;
- int age = -1;
- float balance = 0.0f;
- cout << "Please type in your name: ";
- getline(cin, name);
- while(name.empty()) {
- cout << "Invalid name, it need to atleast not be empty" << endl;
- getline(cin, name);
- }
- cout << "Please type in your age: ";
- cin >> age;
- while(age < -1 || age > 120) {
- cout << "Invalid age please type in an age between 0 to 119: " << endl;
- cin >> age;
- }
- cout << "Please type in you're balance: ";
- cin >> balance;
- while(balance < 0.0f) {
- cout << "Invalid balance please type a balance, any amout thats not less than zero." << endl;
- cin >> balance;
- }
- cout << endl;
- cout << "Hello " << name << " and your age is " << age << endl;
- cout << "and you have $" << setiosflags(ios::fixed) << setprecision(2) << balance << " in your bank account!!!" << endl;
- cout << endl;
- cout << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement