Professional Documents
Culture Documents
IGS2130-001]
Name: Akhrorbek
ID: 12214752
LAB 4
Homework 2
2023/09/26
Question1
#include <iostream>
using namespace std;
// Function prototypes
void sort3(double& a, double& b, double& c, bool (*compare)(double&, double&));
void print3(const double& a, const double& b, const double& c);
void swap2(double& a, double& b);
bool ascending(double& a, double& b);
bool descending(double& a, double& b);
int main() {
// Initializes variables
double na1 = 10.3, na2 = -2.1, na3 = 8.0;
double nd1 = 10.3, nd2 = -2.1, nd3 = 8.0;
return 0;
}
Question 2
Main:
#include <iostream>
#include "bank.h"
using namespace std;
int main(void) {
int choice;
while (1) {
ShowMenu();
cout << "Select menu: ";
cin >> choice;
cout << endl;
switch (bank(choice)) {
case bank::MAKE:
MakeAccount();
break;
case bank::DEPOSIT:
DepositMoney();
break;
case bank::WITHDRAW:
WithdrawMoney();
break;
case bank::INQUIRE:
ShowAllAccInfo();
break;
case bank::EXIT:
return 0;
default:
cout << "Illegal selection.." << endl;
}
}
return 0;
}
Bank.h:
#include <iostream>
#include "bank.h"
using namespace std;
if (GetAccIdx(id) != -1) {
cout << "Error: Existing account ID" << endl;
return;
}
accArr[accNum].accID = id;
accArr[accNum].balance = balance;
strncpy(accArr[accNum].cusName, name, NAME_LEN - 1);
accArr[accNum].cusName[NAME_LEN - 1] = '\0';
accNum++;
cout << "Account created successfully." << endl;
}
accArr[i].balance -= money;
cout << "Withdrawal completed" << endl << endl;
return;
}
}
cout << "This ID is not valid." << endl << endl;
}
Bank.cpp:
#include <iostream>
#include "bank.h"
using namespace std;
void ShowMenu(void) {
cout << "-----Menu------" << endl;
cout << "1. Make Account" << endl;
cout << "2. Deposit" << endl;
cout << "3. Withdrawal" << endl;
cout << "4. Display all" << endl;
cout << "5. Exit program" << endl;
}
void MakeAccount(void) {
// Implementation of MakeAccount function
}
void DepositMoney(void) {
// Implementation of DepositMoney function
}
void WithdrawMoney(void) {
// Implementation of WithdrawMoney function
}
void ShowAllAccInfo(void) {
// Implementation of ShowAllAccInfo function
}