#include #include #include #include #include using namespace std; void ChooseAcarMenu(); void AfterSuccessfulLogin() { int x, accountBalance,paidinamount,number; accountBalance = 15000; do { cout << "Welcome to the ATM cash deposit machine \n" << "Choose one of the options: \n" << "\n1. Checking account status." << "\n2. Deposit money." << "\n3.Redirect you to choose a car" << "\nPlease enter the number:"; cin >> x; system("cls"); switch (x) { case 1: cout << "Checking account balance ..."; Sleep(1000); cout << "\nPlease wait ..."; Sleep(1000); system("cls"); cout << "Your account balance is: " << accountBalance + paidinamount << " zl"; Sleep(1000); system("cls"); cout << "Option:" << "\n1. Return to main menu" << "\n2. Exit"; cout << "\n\nEnter a number "; cin >> number; if (number == 2) { system("cls"); cout << "Exit.\n"; Sleep(2000); exit(0); } else { system("cls"); cout << "In a moment you will be redirected to the main menu ..."; Sleep(2000); system("cls"); break; } case 2: cout << "What amount do you want to pay? \n"; cout << "Amount to be paid:"; cin >> paidinamount; system("cls"); if ((paidinamount >= 1) && (paidinamount <= 1000000)) { system("cls"); cout << "Please put cash. There will be a payment in a moment " << paidinamount << " zl\n"; Sleep(2000); system("cls"); cout << "Please wait..."; Sleep(2000); system("cls"); cout << "Your money has been paid.\n"; cout << "The current account balance is " << accountBalance + paidinamount << "zl"; Sleep(2000); system("cls"); cout << "Thank you for using the services."; Sleep(2000); system("cls"); cout << "In a moment you will be redirected to the main menu ..."; Sleep(2000); system("cls"); break; } else { cout << "You have entered an incorrect number or amount is not supported by our system."; Sleep(2000); system("cls"); cout << "Option:" << "\n1. Return to main menu" << "\n2. Exit"; cout << "\n\nEnter a number "; cin >> number; } if (number == 2) { system("cls"); cout << "Exit.\n"; Sleep(2000); exit(0); } else { system("cls"); cout << "In a moment you will be redirected to the main menu ... "; Sleep(2000); system("cls"); break; } case 3: { cout << "Thank you for using our services" << endl; ChooseAcarMenu(); } } } while (x != 3); } void LogToAccount() { string login = "12345"; string pin = "1234"; string lo; //login auxiliary variable string pn; //pin auxiliary variable cout << "Welcome to the bank!" << endl; cout << "Please login to the account" << endl; cout << "Enter a login: "; cin >> lo; if (lo != login) { cout << "BAD LOGIN!" << endl; cout << "Try again!" << endl; system("cls"); LogToAccount(); } else if (lo == login) { cout << "pin:"; cin >> pn; if (pn != pin) { cout << "bad pin!" << endl; cout << "TRY AGAIN!" << endl; system("cls"); LogToAccount(); } else { cout << "Logged in"; system("cls"); AfterSuccessfulLogin(); } } } void EnoughMoney() { string answer = "Yes"; cout << "Do you have enough money in the bank?(Yes/No)" << endl; cin >> answer; if (answer != "Yes") { cout << "You must deposit money!" << endl; system("cls"); LogToAccount(); } else if (answer == "Yes") { cout << "You buy this car! Congratulations" << endl; } } struct car { car(string m, string mo, string ye, string ca, string HP, string pr, string ft); void printToStdout(); private: string mark;//marka string model;//model string yearbook;//rocznik string capacity;//pojemnosc string price;//cena string Fuel_Type; string Horsepower; }; car::car(string m, string mo, string ye, string ca, string HP, string pr, string ft) { mark = m; model = mo; yearbook = ye; capacity = ca; price = pr; Fuel_Type = ft; Horsepower = HP; } void car::printToStdout() { cout << "The car brand: " << mark << endl; cout << "Car model: " << model << endl; cout << "Car capacity: " << capacity << endl; cout << "Number of horsepower: " << Horsepower << endl; cout <<"Car's production date: " << yearbook << endl; cout << "Fuel type is: " << Fuel_Type << endl; cout <<"The price is: " << price << " zlotych" << endl; EnoughMoney(); } void ChooseAcarMenu() { int answer; cout << "[1]Opel" << endl; cout << "[2]Ford" << endl; cout << "[3]Audi" << endl; cout << "[4]BMW" << endl; cout << "[5]Mercedes-Benz" << endl; cin >> answer; switch (answer) { case 1: { car opel("Opel", "Insignia", "2019", "1.9", "150", "185 000", "Benzine"); opel.printToStdout(); break; } case 2: { car ford("Ford", "Mustang", "2020", "5.2", "760", "800 000", "Benzine"); ford.printToStdout(); break; } case 3: { car audi("Audi", "RS7", "2018", "4.9", "620", "400 000", "Benzine"); audi.printToStdout(); break; } case 4: { car BMW("BMW", "M5", "2019", "4.4", "600", "627 303", "Benzine"); BMW.printToStdout(); break; } case 5: { car mercedes("Mercedes-Benz", "CLS", "2019", "2.0", "245", "325 000", "Diesel"); mercedes.printToStdout(); break; } } } int main() { string answ = "Yes"; cout << "Hello !" << endl; cout << "Do you want buy new car?(Yes/No)" << endl; cin >> answ; if (answ != "Yes") { cout << "go out"; } else { system("cls"); cout << "Cars available for sale: " << endl; ChooseAcarMenu(); } }