C++ File
C++ File
CODE:
#include <iostream>
#include <string>
class BankAccount {
private:
string depositorName;
string accountNumber;
string accountType;
double balance;
public:
if (amount > 0) {
balance += amount;
} else {
balance -= amount;
} else {
};
int main() {
myAccount.display();
myAccount.deposit(500.00);
myAccount.withdraw(200.00);
myAccount.withdraw(2000.00);
myAccount.display();
return 0;
OUTPUT:
Q2.
CODE:
#include <iostream>
#include <cstdlib>
#include <ctime>
void playGame() {
int userGuess = 0;
cout << "I have a number between 1 and 1000." << endl;
while (!guessedCorrectly) {
guessedCorrectly = true;
int main() {
srand(static_cast<unsigned int>(time(0)));
playGame();
return 0;
OUTPUT:
Q3.
CODE:
#include <iostream>
#include <string>
class Account {
protected:
string customerName;
string accountNumber;
string accountType;
double balance;
public:
customerName = name;
accountNumber = accNumber;
accountType = accType;
balance = initialBalance;
if (amount > 0) {
balance += amount;
} else {
balance -= amount;
} else {
cout << "Interest computation not applicable for this account type." << endl;
cout << "Minimum balance check not applicable for this account type." << endl;
};
private:
double minBalance;
double serviceCharge;
public:
void initialize(string name, string accNumber, double initialBalance, double minBal, double charge)
{
minBalance = minBal;
serviceCharge = charge;
balance -= amount;
} else {
cout << "Withdrawal would result in balance below minimum required." << endl;
balance -= serviceCharge;
cout << "Minimum balance not maintained. Service charge imposed: $" << serviceCharge <<
endl;
};
private:
double interestRate;
public:
interestRate = rate;
balance += interest;
cout << "Interest computed and added: $" << interest << endl;
};
int main() {
CurrAcct currentAccount;
SavAcct savingsAccount;
currentAccount.displayBalance();
savingsAccount.displayBalance();
// Perform transactions
currentAccount.deposit(200.00);
currentAccount.withdraw(150.00);
currentAccount.displayBalance();
cout << "\nPerforming transactions on Savings Account:" << endl;
savingsAccount.deposit(300.00);
savingsAccount.displayBalance();
return 0;
OUTPUT:
Q4.
CODE:
#include <iostream>
#include <vector>
int main() {
cout << "Enter votes for the candidates (1 to 5). Enter 0 to end voting." << endl;
while (true) {
int vote;
if (vote == 0) {
break;
voteCounts[vote - 1]++;
} else {
spoiltBallots++;
cout << "Candidate " << (i + 1) << ": " << voteCounts[i] << " votes" << endl;
return 0;
OUTPUT: