Thread: need help assignment

  1. #1
    Registered User
    Join Date
    Nov 2010
    Posts
    10

    need help assignment

    You can see what im trying to do, pls help me, Im having trouble with the if, else if on the bonusContribution, pls help

    Code:
    #include <iostream>
    #include <string>
    #include <iomanip>
    using namespace std;
    int main()
    {
    	int tiksold;
    	double newadmpt, mondist, revgen,amnovrhd,monraised,admpct,bonusContribution;
    	string charname;
    	const double tikprice=5.00;
    	cout<<"How many tickets were sold? "<<endl;
    	cin>>tiksold;
    	cout<<"What percent goes to administrative costs (type in whole number)? "<<endl;
    	cin>>admpct;
    	newadmpt=admpct/100;
    		cout<<"How much prize money was distributed? "<<endl;
    	cin>>mondist;
    	cout<<"What is the name of the charity? "<<endl;
    	cin.ignore();
    		getline (cin,charname);
    revgen=tiksold*tikprice;
    amnovrhd=newadmpt*revgen;
    		
    monraised=(revgen-amnovrhd)-mondist;
    		cout << fixed << showpoint << setprecision(2);
            cout<<"Charity:                               "<<setw(12)<<charname<<endl;
    		cout<<"Revenue generated:                    $"<<setw(12)<<revgen<<endl;
    		cout<<"Administrative overhead:              $"<<setw(12)<<amnovrhd<<endl;
    		cout<<"Deducted prize money:                 $"<<setw(12)<<mondist<<endl;
    		cout<<"Money raise for charitable fund:      $"<<setw(12)<<monraised<<endl;
    		
    		
    	if (tiksold>10000) bonusContribution=0;
    	
    	else if ((tiksold<10000) && (tiksold<25000))bonusContribution=3000;
    	
    	else if (tiksold<24999 && tiksold>50000)bonusContribution=8000;
    	
    	else if (tiksold<49999 && tiksold>100000)bonusContribution=15000;
    	
        else if (tiksold<99999)bonusContribution=25000;
    	
    	
    		cout<<"Bonus Contribution                    $"<<setw(12)<<bonusContribution;
    	
    	
    	
    	return 0;
    }
    Last edited by jekkler; 11-05-2010 at 10:00 PM.

  2. #2
    Registered User
    Join Date
    May 2010
    Posts
    4,632
    So what kind of trouble are you having?

    Does the code compile without errors/warnings?

    If not please post the entire error messages.

    Is it does compile what are your inputs, your outputs, what did you expect?

    Jim

  3. #3
    Registered User
    Join Date
    Nov 2010
    Posts
    10
    Where I'm trying to define bonusContribution it always = 0 when the program runs, im not getting any errors tho... I need the bonusContribution to come out like I'm trying to write it, what am I doing wrong with the else and else if statments?

  4. #4
    Registered User
    Join Date
    May 2010
    Posts
    4,632
    What are your inputs?

    What did you expect?

    Jim

  5. #5
    Registered User
    Join Date
    Nov 2010
    Posts
    10
    I don't understand what your asking me....

  6. #6
    Lurking whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    9,612
    >> if (tiksold>10000) bonusContribution=0;
    Why would you earn no bonus for selling so many tickets?

    >>else if ((tiksold<10000) && (tiksold<25000))
    Couldn't be what you want. What number less than 10000 is not also less than 25000?

    >> else if (tiksold<49999 && tiksold>100000)
    No single number satisfies this.

  7. #7
    Registered User
    Join Date
    May 2010
    Posts
    4,632
    This is an input:

    Code:
     
    	cout<<"How many tickets were sold? "<<endl;
    	cin>>tiksold;
    What did you input?

    You are getting a 0 for your output.

    What did you think your program would produce?

    Jim

  8. #8
    Registered User
    Join Date
    Nov 2010
    Posts
    10
    thanks, that answers the question, I had the < > backwards

  9. #9
    Registered User
    Join Date
    Nov 2010
    Posts
    10
    Charity: "Good Intentions"
    Revenue generated from ticket sales: $ 250000.00
    Amount deducted for administrative overhead: $ 5000.00
    Amount deducted for prize money: $ 15000.00
    Bonus contribution: $ 15000.00

    is what i was going for, I may need help again in a few if your up for it

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Menu
    By Krush in forum C Programming
    Replies: 17
    Last Post: 09-01-2009, 02:34 AM
  2. Assignment Operator, Memory and Scope
    By SevenThunders in forum C++ Programming
    Replies: 47
    Last Post: 03-31-2008, 06:22 AM
  3. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  4. Help with a pretty big C++ assignment
    By wakestudent988 in forum C++ Programming
    Replies: 1
    Last Post: 10-30-2006, 09:46 PM
  5. Replies: 1
    Last Post: 10-27-2006, 01:21 PM