How can i make a chequebook balancing program of an user’s account?
It will use getline() to read a line, which will contain either the word “withdrawl” or “deposit”.
The next line will contain the amount of the withdrawl 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 datatype float, and you can use the function atof() to convert an amount string read by getline() into a floating-point number.
When the program reaches end-of-file, it should exit.

Recommended Answers

All 8 Replies

> Give me a chequebook balancing program.
How presumptuous of you that you think you can just roll in here and demand that we do your homework.

True or false - this applies to you as well as all the other noobs?
Announcement: We only give homework help to those who show effort

commented: Boolean arithmetic is an advanced topic. You might had set expections too high. +13

Please give me a hint to make this program!

Salem gave you a hint already, but if you feel you need more I'll give you another.

Search for your answer first!; the first point from Read This Before Posting, at the head of the forum.

The hints in your homework seem pretty massive from where I'm sitting.

> It will use getline() to read a line
There you go, write a program using getline() and see what happens.

IS getline() INBUILD FUNCTION?
AND HOW IS IT WORKS?

Erm, tell me this isn't the first ever program you've written.

And yes getline() is a function in C++.
I know you've posted on the C forum, but I figured the assignment knew more than you did, and the intention was for you to use C++.

If that's not the case (and it's really C), then you need to write your own (hint: use fgets).

There you go, a program to print a balanced checkbook

#include <stdio.h>
int main ( ) {
    printf(
        "CHECKBOOK\n"
        "=========\n"
        "    ^\n"
        );
    return 0;
}
commented: Loved the sarcasm ;-) +13

There you go, a program to print a balanced checkbook

Well I learnt something from this thread

printf(
        "CHECKBOOK\n"
        "=========\n"
        "    ^\n"
        );

Had no idea you could do that in C.

commented: :) at least someone got something out of it +32
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.