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;