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

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...
use linux or c program. please provide the answer in details. Write a program that will...
use linux or c program. please provide the answer in details. Write a program that will simulate non - preemptive process scheduling algorithm: First Come – First Serve Your program should input the information necessary for the calculation of average turnaround time including: Time required for a job execution; Arrival time; The output of the program should include: starting and terminating time for each job, turnaround time for each job, average turnaround time. Step 1: generate the input data (totally...
Write a C++ program to read in a list of 10 integers from the keyboard. Place...
Write a C++ program to read in a list of 10 integers from the keyboard. Place the even numbers into an array called even, the odd numbers into an array called odd, and the negative numbers into an array called negative. Keep track of the number of values read into each array. Print all three arrays after all the numbers have been read. Print only the valid elements (elements that have been assigned a value). a. Use main( ) as...
Write a C# console program that fills the right to left diagonal of a square matrix...
Write a C# console program that fills the right to left diagonal of a square matrix with zeros, the lower-right triangle with -1s, and the upper left triangle with +1s. Let the user enter the size of the matrix up to size 21. Use a constant and error check. Output the formatted square matrix with appropriate values. Refer to the sample output below. Sample Run: *** Start of Matrix *** Enter the size of square (<= 21): 5 1 1...
Write a C++ console program that prompts a user to enter information for the college courses...
Write a C++ console program that prompts a user to enter information for the college courses you have completed, planned, or are in progress, and outputs it to a nicely-formatted table. Name the CPP as you wish (only use characters, underscores and number in your file name. DO NOT use blank). Its output should look something like this: Course Year Units Grade ---------- ---- ----- ----- comsc-110 2015 4 A comsc-165 2016 4 ? comsc-200 2016 4 ? comsc-155h 2014...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT