Problem 1

This exercise focuses on creating a class that contains a collection of functions that can be used without an instance object of the class to exist. Present both the class and the main program that helps you to test all members’ class function.

Define a class named Utility to incorporate the following static functions. The developer must provide the definition of the functions by defining the proper formal parameters and return value. The following utility member functions should be implemented in the Utility class:

  • You can convert kilograms to pounds. The conversion relation is 1Kg=2.20462262 pounds. Write a member function that allows the user to enter a floating point number representing the weight, the type of measurement unit (K=Kilogram or P=Pound) and display the other corresponding weight.
  • A member function that returns the number of occurrences of a character in an input string (both passed as formal parameters).
  • A member function to reverse in place the order of a given character array.
  • A member function “CompareStrings” that would compare two strings (similar to strcmp “C” library function but do not use strcmp function) that returns 1 when the first string is grater (in lexicographical order) than the second one, 0 if the two strings are equal and -1 otherwise.

Problem 2

This exercise emphasizes the development of designing a C++ class. Attention would be given in the way the member variables and member functions are grouped together and are grouped under different access levels, as well as the signature of functions.

Write a C++ class “Account” to model a bank account and save the class definition in the Account.h file and the class implementation in Account.cpp file. The bank account class should have the following class members visible only to the member functions:

  • Owner first name
  • Owner last name
  • SIN number
  • Balance of the account
  • Type of account (saving or checking)
  • Number of transactions

All the above class members must be initialized when the customer opens the account using the constructor of the class in the main program. For each transaction (deposit and withdraw) the Number of transactions should be incremented by one.

The following member functions would be provided in order to support transactions with the bank account:

  • DepositAmt
  • WithdrawAmt
  • PrintStatement
  • getFinalBalance

You must define the type of the member variables and the right signature (type of the parameters and return type of a function) of the member functions. The “DepositAmt” and “WithdrawAmt” functions would return the final balance. You need to pass as parameter the amount you deposit or withdraw respectively.

Error checking and handling would be appreciated for a withdraw exceeding the balance and a return error should be return in this case through the return of the function.

Have the program display to the standard output the account’s statement as below when accessing the PrintStatement member function:

First Name : John
Last Name : Doe
SIN : 111-222-333
Account Type : Checking
Total Transactions: 13
Final Balance : 1200

Preprocessor definitions statements must be used to guarantee the uniqueness of the inclusion of the header file.

The main program should:

  • include the header file
  • get values to initialize the class member through the standard input (use “cout” to prompt for the input and get the entered values using “cin”).
  • Create the account object by using its constructor that initializes all member variables of the class
  • Ask for an amount to be deposited (use “cout” and “cin”)
  • Apply it to the account
  • Ask for an amount to be withdrawn (use “cout” and “cin”)
  • Apply it to the account
  • Print the statement of the account
Academic Honesty!
It is not our intention to break the school's academic policy. Projects posted are only used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly fill out the form. Please provide a valid email address and we'll get back to you in less than 24 hours. We will be sending an invoice through PayPal upon confirmation. We are a non profit organization however we need an amount to keep this organization running, and to be able to complete our research and development.