a little help please
so im working on my assignment and it says
Percentage of ticket revenue which goes to administrative costs. This input will be entered in percent format (see sample runs below); your program must convert this to a decimal fraction. For example, the user enters 25% as 25, not .25; you convert the 25 to .25 in your code.
how do i conver for example 25 to .25??
anbuninja
Junior Poster in Training
61 posts since Mar 2008
Reputation Points: 10
Solved Threads: 0
so im working on my assignment and it says
Percentage of ticket revenue which goes to administrative costs. This input will be entered in percent format (see sample runs below); your program must convert this to a decimal fraction. For example, the user enters 25% as 25, not .25; you convert the 25 to .25 in your code.
how do i conver for example 25 to .25??
How about dividing 25 by 100?
VernonDozier
Posting Expert
5,527 posts since Jan 2008
Reputation Points: 2,633
Solved Threads: 711
hmmm im really stuck
so this is what we need to do
This program will take user input in the following order:
Number of tickets sold.
Percentage of ticket revenue which goes to administrative costs. This input will be entered in percent format (see sample runs below); your program must convert this to a decimal fraction. For example, the user enters 25% as 25, not .25; you convert the 25 to .25 in your code.
Total amount of prize money distributed.
Name of charity. The name may consist of more than one word (that is, have embedded spaces).
The program then will output the following information in the following order:
Name of charity.
Total revenue generated from the ticket sales. The price of each ticket is currently fixed at $5.00.
Total amount of administrative overhead.
Total amount of prize money overhead.
Balance remaining for the charitable fund
example run
How many tickets were sold? 50000
What percentage of the ticket revenue goes to administrative costs? 2
How much total money is distributed in prizes? 15000
What is the name of the charity? Good Intentions
Charity: Good Intentions
Revenue generated from ticket sales: $ 250000.00
Amount deducted for administrative overhead: $ 5000.00
Amount deducted for prize money: $ 15000.00
Balance raised for charitable fund: $ 230000.00
thats all i got so far >,<, any help? im lost
#include<iostream>
#include<iomanip>
#include<string>
using namespace std;
int main()
{
int ticketssold, percentticket, moneyprizes;
string charity;
cout <<"1.Number of tickets sold?: ";
cin >> ticketssold;
cout <<"2.What percentage of the ticket revenue goes to administrative costs?: ";
cin >> percentticket;
cout <<"3.How much total money is distributed in prizes?: ";
cin >> moneyprizes;
cin.ignore();
cout <<"4.What is the name of the charity?: ";
getline(cin,charity);
cout << left <<"Charity:" << right << setw(50) << charity << endl;
cout << left <<"Revenue generated from ticket sales:" << right
system("pause");
return 0;
}
anbuninja
Junior Poster in Training
61 posts since Mar 2008
Reputation Points: 10
Solved Threads: 0
hmmm im really stuck
First off I agree with VernonDozier, just divide your percentage value by 100 to get a decimal.
#include<iostream>
#include<iomanip>
#include<string>
using namespace std;
int main()
{
int ticketssold, percentticket, moneyprizes;
string charity;
cout <<"1.Number of tickets sold?: ";
cin >> ticketssold;
Where is the variable to contain the value for each ticket sold?? You can't generate a percentage without a value to go along with it.
cout <<"2.What percentage of the ticket revenue goes to administrative costs?: ";
cin >> percentticket;
For this you can add another int called percent (or whatever you want and add the following
percent = percentticket / 100;
But again without having an int variable that totals up the actual revenue from ticket sales, the above is pointless.
cout <<"3.How much total money is distributed in prizes?: ";
cin >> moneyprizes;
cin.ignore();
cout <<"4.What is the name of the charity?: ";
getline(cin,charity);
cout << left <<"Charity:" << right << setw(50) << charity << endl;
cout << left <<"Revenue generated from ticket sales:" << right
You are display text, but not calling up the variables that have your data stored for the ticket sales, that is kinda important to have, otherwise the user will never know the actual answer.
RayvenHawk
Junior Poster in Training
77 posts since Aug 2008
Reputation Points: 32
Solved Threads: 2
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
using namespace std;
int main()
{
int ticketssold, percentticket, moneyprizes, ticketstotal;
string charity;
<strong>cout <<"1.Number of tickets sold?: ";
cin >> ticketssold;
ticketstotal = 5.00 * ticketssold;</strong>
cout <<"2.What percentage of the ticket revenue goes to administrative costs?: ";
cin >> percentticket;
cout <<"3.How much total money is distributed in prizes?: ";
cin >> moneyprizes;
cin.ignore();
cout <<"4.What is the name of the charity?: ";
getline(cin,charity);
cout << left <<"Charity:" << right << setw(50) << charity << endl;
cout << ticketstotal;
system("pause");
return 0;
}
okay i got 1. updated but im still lost in question 2. about the percent.
ohhh and i know at the end i havent called out all the variables i know how to do that its just that im soo stuck in the input.
anbuninja
Junior Poster in Training
61 posts since Mar 2008
Reputation Points: 10
Solved Threads: 0
alright so little by little im completing this program.
heres my updated code
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
using namespace std;
int main()
{
int ticketssold, moneyprizes, ticketstotal;
string charity;
float percentticket;
cout <<"1.Number of tickets sold?: ";
cin >> ticketssold;
ticketstotal = 5.00 * ticketssold;
cout <<"2.What percentage of the ticket revenue goes to administrative costs?: ";
cin >> percentticket;
cout <<"3.How much total money is distributed in prizes?: ";
cin >> moneyprizes;
cin.ignore();
cout <<"4.What is the name of the charity?: ";
getline(cin,charity);
cout <<"Charity:" << right << setw(55) << charity << endl;
cout <<"Revenue generated from ticket sales:" << right << fixed << setprecision(2) << setw(16) << '$'
<< ticketssold * 5 << endl;
cout <<"Amount deducted for administrative overhead:" << right << fixed << setprecision(2) << setw(8) << '$'
<< percentticket/100. * ticketstotal << endl;
system("pause");
return 0;
}
now im having issues on calculating these thingsAmount deducted for prize money: $ 15000.00
Balance raised for charitable fund: $ 230000.00
and idk why but the setprecision is not working on
Revenue generated from ticket sales: $ 250000.00
it works fine for
Amount deducted for administrative overhead: $ 5000.00
?????
anbuninja
Junior Poster in Training
61 posts since Mar 2008
Reputation Points: 10
Solved Threads: 0
alright thanks Denniz :D
im almost finished just one problem. when i run it instead of getting 230000.00 i get 234998.00 ? im using float now no more int.
anbuninja
Junior Poster in Training
61 posts since Mar 2008
Reputation Points: 10
Solved Threads: 0
ok i got it
(ticketstotal - moneyprizes - percentticket/100.) but i get 234999.98 how do i round it off so it can be 2350000.00?
anbuninja
Junior Poster in Training
61 posts since Mar 2008
Reputation Points: 10
Solved Threads: 0
anbuninja
Junior Poster in Training
61 posts since Mar 2008
Reputation Points: 10
Solved Threads: 0