-
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;
}
-
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
-
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?
-
What are your inputs?
What did you expect?
Jim
-
I don't understand what your asking me....
-
>> 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.
-
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
-
thanks, that answers the question, I had the < > backwards
-
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