0% found this document useful (0 votes)
9 views

Programming Fundamental Assignment 2

The bank offers two types of accounts: savings and checking. Savings accounts earn 4% interest if the balance is above the minimum, and checking accounts earn 3-5% interest depending on how far above the minimum balance is. The program defines variables to store the account type, balance, and minimum balance entered by the user. It then calculates any service charge if the balance is below the minimum, and calculates the interest earned based on the account type and balance. The new balance is displayed after subtracting any service charge and adding interest.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Programming Fundamental Assignment 2

The bank offers two types of accounts: savings and checking. Savings accounts earn 4% interest if the balance is above the minimum, and checking accounts earn 3-5% interest depending on how far above the minimum balance is. The program defines variables to store the account type, balance, and minimum balance entered by the user. It then calculates any service charge if the balance is below the minimum, and calculates the interest earned based on the account type and balance. The new balance is displayed after subtracting any service charge and adding interest.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Programming fundamental

Assignment no 2

Program no 12

A bank in your town updates its customers accounts at the end of each month. The bank offers two
types of accounts: savings and checking. Every customer must maintain a minimum balance, If a
customer’s balance fall below the minimum balance, there is a service charge of $10.00 for savings
accounts and $25.00 for checking accounts. If the balance at the end of the month is at least the
minimum balance, the account receives interest as follows

A. Savings accounts receive 4% interest.

B. Checking accounts with balances of up to $5,000 more than the minimum balance receive 3% interest;
otherwise, the interest is 5%

Solution:

#include <iostream>

using namespace std;

int main()

Char account type;

Double balance, mini Balance;

cout << “Enter account type (S or C): “;

cin >> account type;

cout << “Enter current balance and minimum balance: “;

cin >> balance >> mini balance;

Double service charge = (account type == ‘S’ || account type == ‘s’) ? (balance < mini balance ? 10.0 :
0.0) : (balance < mini balance ? 25.0 : 0.0);

Double interest = (account type == ‘S’ || account type == ‘s’) ? (balance < mini balance ? 0.0 : balance *
0.04) : (balance < mini balance ? 0.0 : (balance – mini balance <= 5000.0 ? (balance – mini balance) *
0.03 : 5000.0 * 0.03 + (balance – mini balance – 5000.0) * 0.05));

Double new balance = balance – service charge + interest;

cout << “Service Charge: $” << service charge << “\n Interest Earned: $” << interest << “\n New Balance:
$” << new balance <<endl;

return 0;
}

Program no 13

Write a program that implements the algorithm given in Example 1-3 (Chapter 1), which determines the
monthly wages of a salesperson

Solution:

#include <iostream>

using namespace std;

int main()

Double fixed salary, commission rate, total sales;

// Input fixed salary, commission rate, and total sales

cout << “Enter fixed salary: $”;

cin >> fixed salary;

cout << “Enter commission rate (as a decimal): “;

cin >> commission rate;

cout << “Enter total sales: $”;

cin >> total sales;

// Calculate monthly wages

Double commission = commission rate * total sales;

Double monthly wages = fixed salary + commission;

// Display the result

cout << “Monthly Wages: $” << monthly wages << endl;

Return 0;

You might also like