Академический Документы
Профессиональный Документы
Культура Документы
Question 2
Declare an array, which can hold 5 integer elements. The user should be given the
opportunity to enter 5 values into the array from the keyboard.
a) Using a pointer, store the values that the user has entered in the array.
b) Calculate and display the average of the array elements.
c) Arrange the values in the array according to descending order (from the highest
value to the lowest value) and display the answer.
Hint: You should use nested loops and a temporary variable in order to arrange the
values in descending order.
Question 3
You need to write a password registration programme. Your programme should be
structured in the flowing way.
Take user input
(first name, last name, user name, password
Question 4
Write a programme, which is a bank account, which records the balance of money for
a given customer. Your programme should perform the three transactions given below.
a) Checking the bank balance- Bank balance may have a positive or credit balance
where the bank holds money on behalf of the customer; or a negative or debit balance
where the customer owes the bank money. If the bank balance is a negative value you
should display a message indicating that the customer has a debit value. If the bank
balance is zero you should display a message indicating that the account has no
money.
b) Deposit money – The money that the customer deposits should be added to the
balance.
c) Withdraw money- The money that the customer withdraws should be deducted
from the balance.
Define a class called ‘Account’. You should define three different public member
functions in order to carry out the above three transactions and a private member data
called ‘balance’ in order to perform the calculations. Define a constructor which
initializes the default bank balance to zero (0). You should define a destructor for the
class as well.
Create three objects as given below and perform the following transactions and
display the balance to the user.
Object Name Initial Balance Deposit Withdrawal Balance
Nimal 0 500 - ?
Kamal 100 400 200 ?
Saman -400 400 - ?