Question
Use Dec-C++ compiler
Problem 13, Chapter 8 Programming Exercises 8.3 8.3. Write a program CHECKBOOK that prompts the user for an amount and either + or -. If the user enters +, then balance, an extern variable, is incremented by the amount. If the user enters -, then balance is decremented by the amount. Two functions, deposit and withdraw, perform the updating operations.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

I have written the program using CPP PROGRAMMING LANGUAGE .

TASK : to write the deposit and withdraw functions in order to update the balance extern variable .

INPUT :

extern int balance = 1000;

OUTPUT :

For deposit :

No description e(discord bots) Files main.cpp saved gcc version 4.6.3 #include <iostream> //included 10stream module main.cpp 2 using namespace std; main.cpp:4:12: warning balance initialized and declared extern extern int balance 1e00; //initialized and declared variable balance extern int balance 1eee; initialized and declared variable balance 5 function definition for deposit 6 void deposit(int amount) 250 Enter an amount: Please enter +or + is for deposit -is for withdraw. Please enter either + or - Please enter + or + is for deposit - is for withdraw: balance amount;//increamented balance by amount 9 //function definition for withdraw 1 void withdraw(int amount) balanceamount; //decremented balance by amount 12 13 //main method 14 int main) f 15 16 17 18 19 Your Remaining balance is 1250 int amount; // declared variable amount char operators;//declared variable operators cout <<Enter an amount:\t; //to print the message on console cin amount;//to take the input from user //used while loop for getting the proper input from user until user enters a valid value while(true)t 20 21 cout << Please enter or \nt is for deposit In- is for withdraw:\t; cin >> operators; if(operators 4){ 23

For Withdraw :

Please find the snippet of code below ..

CODE :

#include <iostream> //included iostream module

using namespace std;

extern int balance = 1000; //initialized and declared variable balance

// function definition for deposit

void deposit(int amount){

balance += amount;//increamented balance by amount

}

//function definition for withdraw

void withdraw(int amount){

balance -= amount; //decremented balance by amount

}

//main method

int main() {

int amount; // declared variable amount

char operators;//declared variable operators

cout << "Enter an amount:\t"; //to print the message on console

cin >> amount;//to take the input from user

//used while loop for getting the proper input from user until user enters a valid value

while(true){

cout << "Please enter + or -\n+ is for deposit \n- is for withdraw:\t";

cin >> operators;

if(operators == '+'){

deposit(amount); // calling deposit function

break; //to break the while loop

}else if(operators == '-'){

withdraw(amount); //calling withdraw function

break; //to break the while loop

}else{

cout << "Please enter either + or -\n";

continue; //to continue the while loop

}

}

//finally printing the remaining balance on console.

cout << "\nYour Remaining balance is "<<balance;

}

Thanks ..

Add a comment
Know the answer?
Add Answer to:
Use Dec-C++ compiler Problem 13, Chapter 8 Programming Exercises 8.3 8.3. Write a program CHECKBOOK that...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Using C programming please 5. Write a multithreaded program to do the following: Accepts two positive...

    Using C programming please 5. Write a multithreaded program to do the following: Accepts two positive integers from the command line as the amounts to withdraw a. and deposit from an account. b. Creates two threads to perform withdraw and deposit operations repectively. Passes the amount to withdraw/deposit as the parameter to thread's runner function c. Waits for both threads to terminate. Since both threads need to update the account balance, it is necessary to protect sections. You may use...

  • Write a C program to make an ATM Management System. Use string functions and file handling...

    Write a C program to make an ATM Management System. Use string functions and file handling in your code. Your program should verify a user by already defined PIN Code and perform deposit/withdraw/check account balance Edit: it is a console program

  • C++ Check Book Program I need to have a checkbook program that uses the following items....

    C++ Check Book Program I need to have a checkbook program that uses the following items. My code that I have appears below. 1) Math operations using built-in math functions 2) Class type in a separate .h file with member functions (accessor functions, get, set, show, display find, etc). There needs to be an overloaded function base/derived classes or a template. 3) Binary File #include <iostream> using namespace std; int main() {     double checking,savings;     cout<<"Enter the initial checking...

  • C++ Object-Oriented Programming - Program using structs, functions, and a little of overloaded functions. The finished...

    C++ Object-Oriented Programming - Program using structs, functions, and a little of overloaded functions. The finished program should look exactly like the part at the bottom in gray text. Create two structures and name the types Account and Money. The Money struct has two variables One represents how many dollars you have The other represents h ow many cents you have .The Account struct has three variables - A Money struct that will represent how much money is in the...

  • Please mad in dev c++ software That is example. But it is wrong Write a simple...

    Please mad in dev c++ software That is example. But it is wrong Write a simple checkbook balancing program Input will contain either the word "withdraw" or "deposit". The next line will contain the amount of the check or deposit. After reading each pair of lines, the program should compute and print the new balance. You can declare the variable to hold the running balance to be type float, and you can use the function atof (also in the standard...

  • COP 2220 Into programming in C(Answer in C, not C++). The question is: Please write the...

    COP 2220 Into programming in C(Answer in C, not C++). The question is: Please write the algorithm for a AppStore programming assignment. The details of the assignment, a sample algorithm, and its outline, are located below. Make the algorithm at least half a page, easy to read, and to understand, how it works. I just want the algorithm, not the programming code, I have that. I only need the ALGORITHM. Thanks for helping me out, I apprieciate it, have a...

  • write a code on .C file Problem Write a C program to implement a banking application...

    write a code on .C file Problem Write a C program to implement a banking application system. The program design must use a main and the below functions only. The program should use the below three text files that contain a set of lines. Sample data of these files are provided with the assessment. Note that you cannot use the library string.h to manipulate string variables. For the file operations and manipulations, you can use only the following functions: fopen(),...

  • Kindly solve this using C PROGRAMMING ONLY. 4. Write a program marks.c which consists of a...

    Kindly solve this using C PROGRAMMING ONLY. 4. Write a program marks.c which consists of a main function and three other functions called. readmarks , changemarks (, and writemarks() The program begins by calling the function readmarks () to read the input file marksin. txt which consists of a series of lines containing a student ID number (an integer) and a numeric mark (a float). Once the ID numbers and marks have been read into arrays (by readmarks () the...

  • This is a standard C++ programming assignment using a command line g++ compiler or the embedded...

    This is a standard C++ programming assignment using a command line g++ compiler or the embedded one in zyBooks. No GUI forms and no Visual Studio. No external files and no databases are used. There is only one object-oriented program to complete in this assignment. All code should be saved in a file named ExamScoresUpdate.cpp, which is the only file to submit for grading. No .h files used. The .cpp file contains main() and two classes, ExamScores and DataCollector. There...

  • (C++)This is the problem that I'm supposed to write a program for: This is the layout...

    (C++)This is the problem that I'm supposed to write a program for: This is the layout that we are supposed to fill out for the project: If anything is unclear, comment and I'll try to clarify. Thank you! Objective Reading Dala Files Project This is a variation of ng challenge 133 de Write a class named Car that has the following pelvate member variables. model Year An ie car's uodd year. make A string that bolds the make of the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT