Re: help

Posted 26 August 2001 - 11:17 AM

The only thing I get from that message is that he is making checks, but the check number isn't going up by one properly, or at all.
(Check #1, Check #2, Check #3, etc.) The code for that part looks fine to me (I'm still a beginner mind you).
Anyone else have any ideas?

Re: help

Posted 27 August 2001 - 09:12 AM

My problem is just what Jason said, and also that I can't get my program to return to the questions (what is the date, etc...) so the user can enter them. Also, sometimes, when I click y to play again, it skips over the employees function.

Re: help

Posted 27 August 2001 - 03:43 PM

Um...I realize that you're probably doing this assignment for a class, so hopefully (both for your sake and everyone else in the class) I'm not contradicting your teacher...but I'd really recomment not linking the functions together like that. It makes it tougher to debug it, tougher to read it, can pose some problems once you start using local varialbes (and even when you don't), and it doesn't serve a greater purpose. I'd rethink your design, if you have time.
(begin edit)
Just some explanation of myself here.
One of the reasons I say that you shouldn't do that is because the program never leaves any of the functions until the very end of the program. Each time you enter a new function, certain information about the old function is saved, including any local variables that were declared. So say you have two checks to output. The function calls will look like this:
title
employees
date
comp_name
paidto
soc_sec
names
ender
(note that I skip employees() here...that's why it wouldn't show up for you. In ender(), you call date() to start the loop over again, instead of employees())
date
comp_name
...
names
ender
Each of these calls is gonna put more stuff on the stack, and if you do it enough times, you'll get a segmentation fault.
Just a quick note--I'm not trying to be harsh or cut you up here. Just pointing out and explaining myself. :)
(end edit)
With that said...look at the statement just above "k=n+1". You assign 0 to n each time. That's why it's never going up--if you're trying to initialize n to 0, you should do it outside of the "loop" you have going there. Along those lines, you don't even need the variable k, unless you use it for something other than the cout statement that follows a few lines later. All you need to do is increment n by one each time.
Let me know if you have any other questions, and I'll try to clarify myself for you.

Re: help

Posted 28 August 2001 - 08:12 AM

I have changed my program some so that they say whether or not they want to use the checkbook before they say how many employees they have. I figured that if they want to play, then it would ask them for the employee number and then I could use a for loop somewhere, but, when it asks for the employees, I type in a number, and then it skips the date function, and also I tried the for loop, and I couldn't figure it out.
code:
------------------------------------------------------------
//Checkbook
//By : Jeff Golik
//Block 2
#include <iostream.h>
#include <math.h>
#include <stdlib.h>
int k, n, amount;
double gross, state, fed, deduc, overtim, overtime, total, hours, all;
float mon1, stat, feder;
char emp, dat[18], name[21], ss[15], nam[20], order[30];
void title();
void do_again();
void date();
void comp_name();
void soc_sec();
void paidto();
void names();
void head();
void input();
main()
{title();
return 0;}
void title()
{cout<<"Welcome to your checkbook and totaler.

Re: help

Posted 28 August 2001 - 10:36 AM

I think the only truly helpful suggestion I can give you without rewriting your code for you is to take a step back and rethink everything. I'd strongly recommend starting fresh, as well. Think about what you want to accomplish in very high level terms. If I understand your assignment correctly, you have to produce a program that will format and print out one or more sets of data that the user inputs. You don't have to get fancy with it, even if you're required to use functions by the assignment. Think of it in pseudocode:

Until the user decides to stop,
Collect the data
Print out the data

Of course, I'm purposely not getting specific. I think that if you reconceptualize the problem, you'll have a much easier time trying to both code and debug it. Good luck!

Re: help

Posted 31 August 2001 - 09:25 AM

Does anybody have any ideas why my program likes to skip the function right after the do_again function? I ask if they want to play, and if they enter y, then it goes to the
date_comp_name() function, but it skips the date part of the function. Can anyone help me?