Question

In: Computer Science

PLease use c++ Write a checkbook balancing program. The program will read in, from the console,...

PLease use c++

Write a checkbook balancing program. The program will read in, from the console, the following for all checks that were not cashed as of the last time you balanced your checkbook: the number of each check (int), the amount of the check (double), and whether or not it has been cashed (1 or 0, boolean in the array). Use an array with the class as the type. The class should be a class for a check. There should be three member variables to record the check number, the check amount, and whether or not the check was cashed. The class for a check will have a member variable of type Money (as defined on page 662 in the book; Display 11.9) to record the check amount. So, you will have a class used within a class. The class for a check should have accessor and mutator functions as well as constructors and functions for both input and output of a check. In addition to the checks, the program also reads all the deposits (from the console; cin), the old and the new account balance (read this in from the user at the console; cin). You may want another array to hold the deposits. The new account balance should be the old balance plus all deposits, minus all checks that have been cashed.

The program outputs the total of the checks cashed, the total of the deposits, what the new balance should be, and how much this figure differs from what the bank says the new balance is. It also outputs two lists of checks: the checks cashed since the last time you balanced your checkbook and the checks still not cashed.

[ edit: if you can, Display both lists of checks in sorted order from lowest to highest check number.]

Solutions

Expert Solution

#include <iomanip>
#include <iostream>
#include <cmath>
using namespace std;

//Declaring_methods
float Check_process(float, float, float); //check_process_method
float Deposit_process(float, float); //deposit_process_method
float Program_End(float, float); //program_end_method



int main ()
{

  float my_balance = -1; //will_be_used_to_store_balance, -1 for_initial_flag
  char transact_type = 'f'; //transaction_type_(Valid_types: C or D or E)
  int exit1 = 0; //used_to_exit_the_program
  float totServiceChg; // used_to_store_total_service_charges
  const float serviceChg = 0.25; // constant_for_each_service_charge
 
  //Get_initial_balance
  cout << "C++ Check Book Balancing Code\n\n";
  cout << "Please Enter the Starting Account_Balance: ";
  
  
  cin >> my_balance;

  //Round_balance_to_2_decimal_places
  floor(my_balance*pow(10,2))/pow(10,2);
  
  cout << "\nInput_Commands:\n" << "C - Check processing" << "\nD - Depositing";
  cout << "\nE - Exit the Program\n";
 
        
        
        while ( exit1 == 0){
                
                //user_input 
                cout << "\nPlease Input transaction type: ";
                cin >> transact_type;
        
                //checking_for_case
                if (transact_type == 'C'){
                        cout << "Please Enter the transaction amount: ";
                    totServiceChg += serviceChg;
                        floor(totServiceChg*pow(10,2))/pow(10,2);
                        my_balance = Check_process(my_balance, serviceChg, totServiceChg);
                }
                //In_case_of_deposit
                else if (transact_type == 'D'){
                cout << "Please Enter the transaction_amount: ";
                        my_balance = Deposit_process(my_balance, totServiceChg);
                }
                //Exit_or_End_Month_Case
                else if (transact_type == 'E'){
                        cout << "End Month Statement: ";
                        Program_End(my_balance, totServiceChg);
                        exit1 = 1;
                        }               
                else 
                        cout << "Please Enter a correct transaction type. \n";
                }
  return 0;
}


//Check_process method, that returns the new balance
float Check_process(float my_balance, float serviceChg, float totServiceChg){
        float transactionAmount = -1; //flag -1 for_transaction_amount
        
        //Maintains_a_+ve_number_for_transaction
        while (transactionAmount <= -1 ){
        transactionAmount = 1;
        cin >> transactionAmount;
        if (!(transactionAmount > 0))
        cout << "\nPlease Input a positive no. : ";
        }
        
        //process_the_check
        cout << "Initializing check for $" << transactionAmount;
        my_balance -= transactionAmount;
        floor(my_balance*pow(10,2))/pow(10,2);
        cout << "\nCurrent_Balance: $"; 
        cout << setprecision(2) << fixed << my_balance;
        cout << "\nService_charge: $" << serviceChg;
        cout << " as per check policy";
        cout << "\nTotal service_charges: $" ;
        cout << setprecision(2) << fixed << totServiceChg;
        cout << "\n";
        return my_balance;
}

//Deposit+process method, returns_new_balance 
float Deposit_process(float my_balance, float totServiceChg){
        float transactionAmount = -1; // flag -1 for transaction amount
        
        // while_loop_that_maintains_a_+ve_amount
        while (transactionAmount <= -1 ){
                transactionAmount = 1;
        cin >> transactionAmount;
        if (!(transactionAmount > 0))
        cout << "\nPlease enter a positive number: ";
        }

        //Deposit_process
        cout << "Initializing deposit for $" << transactionAmount;
        my_balance += transactionAmount;
        floor(my_balance*pow(10,2))/pow(10,2);
        cout << "\nBalance: $";
        cout << setprecision(2) << fixed << my_balance;
        cout << "\nTotal service_charges: $";
        cout << setprecision(2) << fixed << totServiceChg;
        cout << "\n";
        return my_balance;
}

//End_of_the_program
float Program_End(float my_balance, float totServiceChg){
        my_balance -= totServiceChg;
        cout << "\nFinal_Balance: $";
        cout << setprecision(2) << fixed << my_balance;
        return my_balance;
}

Output :

Summary : C++ Checkbook Balancing Program for bank accounts that reads from input, the transaction type, checking, depositing as per the requirements.

P.S. Hope this code solution helps you out, please give a thumbs up, as you know it was not easy to code all this within 2 hrs. Have a good day !


Related Solutions

Write a checkbook balancing program. The program will read in, from the console, the following for...
Write a checkbook balancing program. The program will read in, from the console, the following for all checks that were not cashed as of the last time you balanced your checkbook: the number of each check (int), the amount of the check (double), and whether or not it has been cashed (1 or 0, boolean in the array). Use an array with the class as the type. The class should be a class for a check. There should be three...
Write a c++ program that inputs a time from the console. The time should be in...
Write a c++ program that inputs a time from the console. The time should be in the format “HH:MM AM” or “HH:MM PM”. Hours may be one or two digits. Your program should then convert the time into a four-digit military time based on a 24-hour clock. Code: #include <iostream> #include <iomanip> #include <string> using namespace std; int main() { string input; cout << "Enter (HH:MM XX) format time: "; getline(cin, input); int h, m; bool am; int len =...
use c++ 1 a)Write a console program that creates an array of size 100 integers. Then...
use c++ 1 a)Write a console program that creates an array of size 100 integers. Then use Fibonacci function Fib(n) to fill up the array with Fib(n) for n = 3 to n = 103: So this means the array looks like: { Fib(3), Fib(4), Fib(5), ...., Fib[102) }. For this part of the assignment, you should first write a recursive Fib(n) function. .For testing, print out the 100 integers. b) For the second part of this assignment, you must...
Write a C++ program to read characters from the keyboard until a '#' character is read....
Write a C++ program to read characters from the keyboard until a '#' character is read. Then the program will find and print the number of uppercase letters read from the keyboard.
Please write a java program to write to a text file and to read from a...
Please write a java program to write to a text file and to read from a text file.
C# Programming Language Write a C# program ( Console or GUI ) that prompts the user...
C# Programming Language Write a C# program ( Console or GUI ) that prompts the user to enter the three examinations ( test 1, test 2, and test 3), homework, and final project grades then calculate and display the overall grade along with a message, using the selection structure (if/else). The message is based on the following criteria: “Excellent” if the overall grade is 90 or more. “Good” if the overall grade is between 80 and 90 ( not including...
Code in C# please. Write a program that will use the greedy algorithm. This program will...
Code in C# please. Write a program that will use the greedy algorithm. This program will ask a user to enter the cost of an item. This program will ask the user to enter the amount the user is paying. This program will return the change after subtracting the item cost by the amount paid. Using the greedy algorithm, the code should check for the type of bill. Example: Cost of item is $15.50 User pays a $20 bill $20...
Program this using C please The program will read from standard input two things - a...
Program this using C please The program will read from standard input two things - a string str1 on the first line of stdin (this string may be an empty string) - a string str2 on the second line of stdin (this string may be an empty string) Note that stdin does not end with '\n'. The program will output a string that is the concatenation of string str1 and string str2 such that any lower-case alphabet character (a-z) will...
For your first project, write a C program (not a C++ program!)that will read in a...
For your first project, write a C program (not a C++ program!)that will read in a given list of non-negative integers and a target integer and checks if there exist two integers in the list that sum up to the target integer. Example:List: 31, 5, 8, 28, 15, 21, 11, 2 Target: 26 Yes!, 44 No! your C program will contain the following: •Write a function that will make a copy of the values from one array to another array....
I need this written in C # ASAP Write a C# console program that continually asks...
I need this written in C # ASAP Write a C# console program that continually asks the user "Do you want to enter a name (Y/N)? ". Use a "while" loop to accomplish this. As long as the user enters either an upper or lowercase 'Y', then prompt to the screen "Enter First and Last Name: " and then get keyboard input of the name. After entering the name, display the name to the screen.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT