Question

In: Computer Science

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 member variables to record the check number, the check amount, and whether or not the check was cashed. 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 <iostream>

#include <cstdlib>

#include <cctype>

#include "checkbook.cpp"

using namespace std;

class checkbook

{

private:

float balance;

public:

void initbalance(float x);

void writecheck(float x);

void makedeposit( float x);

float getbalance() const;

};

//Here is the class definition, checkbook.cpp.

void checkbook::initbalance(float x)

{

if (x >=0)

balance = x;

else

cout <<"Invalid initialization "<<x<<endl;

}

void checkbook::writecheck(float x)

{

if (x > balance)

cout << "Insufficient funds -- current balance is"<<balance<<endl;

else

balance -=x;

}

void checkbook::makedeposit(float x)

{

if (x > 0)

balance += x;

else

cout <<"Invalid Deposit "<<x<<endl;

}

float checkbook::getbalance()const

{

return balance;

}

//Here's a little program which uses the class

int main()

{

    

checkbook mycheckbook; // mycheckbook is an object; checkbook is a class

mycheckbook.initbalance(500.00); // start with a balance of$500

mycheckbook.writecheck(50.0); // write a check for $50

mycheckbook.writecheck(345.76); // write a check for $345.76

mycheckbook.makedeposit(300.0); // make the deposit $300

cout<<"current balance : $"<<mycheckbook.getbalance()<<endl;

return 0;

}

This is my partial solution that you may want to use and modify.give a thumbs up if u get what u asked for,  Please let me know if you need help more.


Related Solutions

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...
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 =...
In this exercise, you’ll write a program that accepts a person’s birth date from the console...
In this exercise, you’ll write a program that accepts a person’s birth date from the console and displays the person’s age in years. To make that easier to do, we’ll give you a class that contains the code for accepting the birth date. The console output for the program should look something like this: f Welcome to the age calculator. j Enter the month you were born (1 to 12) : 5 Enter the day of the month you were...
DO THIS PROGRAM IN JAVA Write a complete Java console based program following these steps: 1....
DO THIS PROGRAM IN JAVA Write a complete Java console based program following these steps: 1. Write an abstract Java class called Shape which has only one abstract method named getArea(); 2. Write a Java class called Rectangle which extends Shape and has two data membersnamed width and height.The Rectangle should have all get/set methods, the toString method, and implement the abstract method getArea()it gets from class Shape. 3. Write the driver code tat tests the classes and methods you...
URGENT!!! DO THIS PROGRAM IN JAVA Write a complete Java console based program following these steps:...
URGENT!!! DO THIS PROGRAM IN JAVA Write a complete Java console based program following these steps: 1. Write an abstract Java class called Shape which has only one abstract method named getArea(); 2. Write a Java class called Rectangle which extends Shape and has two data membersnamed width and height.The Rectangle should have all get/set methods, the toString method, and implement the abstract method getArea()it gets from class Shape. 3. Write the driver code tat tests the classes and methods...
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.
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.
Write a c++ program that does the following, read temperatures from a file name temp.txt into...
Write a c++ program that does the following, read temperatures from a file name temp.txt into an array, and after reading all the temperatures, output the following information: the average temperature, the minimum temperature, and the total number of temperatures read. Thank you!
Write a C program that will read different data types from the following file and store...
Write a C program that will read different data types from the following file and store it in the array of structures. Given file: (This file have more than 1000 lines of similar data): time latitude longitude depth mag magType nst gap dmin 2020-10-19T23:28:33.400Z 61.342 -147.3997 12.3 1.6 ml 12 84 0.00021 2020-10-19T23:26:49.460Z 38.838501 -122.82684 1.54 0.57 md 11 81 0.006757 2020-10-19T23:17:28.720Z 35.0501667 -117.6545 0.29 1.51 ml 17 77 0.1205 2020-10-19T22:47:44.770Z 38.187 -117.7385 10.8 1.5 ml 15 100.22 0.049 2020-10-19T22:42:26.224Z...
Write a program which accepts a sequence of comma-separated numbers from console and generate a list...
Write a program which accepts a sequence of comma-separated numbers from console and generate a list and a tuple which contains every number. Suppose the following input is supplied to the program: 34, 67, 55, 33, 12, 98. Then, the output should be: ['34', '67', '55', '33', '12', '98'] and ('34',67', '55', '33', '12', '98').
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT