Thread: Really Need Some Help.

  1. #1
    Registered User
    Join Date
    Dec 2005
    Posts
    3

    Really Need Some Help.

    First of all I'm a n00b at this so be patient. I have to turn in this program on Wednesday with a presentation. I know it's not finished, but I ran it to see if it'll display my emp of 4 and nothing, no errors, it wouldn't even compile. Any help would be greatly appreciated as my grade is riding on this and I couldn't afford the textbook.

    Code:
    // Business Program Rough Concept #1
    
    #include <iostream>
    using namespace std;
    
    int main()
    {
    	int money, emp, tot, apay, bpay, cpay, dpay, hours, rev, pro, loss, etpa, etpb, etpc, etpd, lCost;
    	float tot, money, apay, cpay, dpay, hours, rev, pro, loss, etpa, etpb, etpc, etpd, lCost;
    
    
    	lCost = (etpa+etpb+etbc+etbd)/float(4);
    	etpa = (emp * apay * hours)float;
    	etpb = (emp * bpay * hours)float;
    	etpc = (emp * cpay * hours)float;
    	etpd = (emp * dpay * hours)float;
    	apay = (5.15)float;
    	bpay = (6.50)float;
    	cpay = (7.00)float;
    	dpay = (10.50)float;
    	base = (1000);
    	rev = (base * 1.1 * month)float;
    	pro = (rev - lCost)float;
    	money = (10000);
    
    	emp = (4);
    	hours = (4);
    
    	
    	cout << emp;
    
    	return 0;
    
    }

  2. #2
    Registered User
    Join Date
    Dec 2005
    Posts
    3
    I have to get some sleep guys. I'm sorry if it sounds like a really retarded question and the mistake is right in front of me, but I'm pretty new to this. The reason why I haven't learned much is because the school took all effin semester to get my my Visual Studio, and when they finally did, it was the wrong program, I had to get it off someone else.

    If you guys could help me out, I'd be really greatful. Goodnight and thanks in advance.

  3. #3
    Deprecated Dae's Avatar
    Join Date
    Oct 2004
    Location
    Canada
    Posts
    1,034
    You don't need all that type-casting. There should be only 1 variable with the same name, and you don't need an int and a float version - work with one or the other. Just make most, if not all, of them floats. e.g. make apay a float, and instead of apay = (5.15)float;, make it apay = 5.15f;. Make it /4.0f instead of /float(4). You need to assign something to your variables before you use them. So in the line lCost = (etpa+etpb+etbc+etbd)/float(4); you should have etpa, etpb, etbc, and etbd already defined before you call that. The same goes for the rest of the variables - they should be defined before you use them. You dont need the parenthesis around 4 in emp = (4);.
    Warning: Have doubt in anything I post.

    GCC 4.5, Boost 1.40, Code::Blocks 8.02, Ubuntu 9.10 010001000110000101100101

  4. #4
    Registered User
    Join Date
    Apr 2003
    Posts
    2,663
    Just make most, if not all, of them floats.
    Why even use floats? Just use type double, and then you don't have to indicate the type of the number literal, e.g.:
    Code:
    double myNum = 2.56;
    rather than:
    Code:
    float myNum = 2.56f;
    Some other things to consider:

    1) Use descriptive variable names. These are not descriptive: etpa, etpb, etpc, etpd

    2) What's with the parentheses?
    Code:
    money = (10000);
    
    emp = (4);
    hours = (4);
    Last edited by 7stud; 12-06-2005 at 09:05 AM.

  5. #5
    Registered User
    Join Date
    Dec 2005
    Posts
    3
    Thanks for the help guys. That's the way they taught it to me. I hope that fixes my problems.

Popular pages Recent additions subscribe to a feed