| | |
a little help please
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Mar 2008
Posts: 61
Reputation:
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??
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??
•
•
Join Date: Jan 2008
Posts: 3,819
Reputation:
Solved Threads: 501
•
•
•
•
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??
•
•
Join Date: Mar 2008
Posts: 61
Reputation:
Solved Threads: 0
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
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
C++ Syntax (Toggle Plain Text)
#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; }
•
•
Join Date: Aug 2008
Posts: 55
Reputation:
Solved Threads: 1
First off I agree with VernonDozier, just divide your percentage value by 100 to get a decimal.
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.
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.
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.
•
•
•
•
C++ Syntax (Toggle Plain Text)
#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;
•
•
•
•
C++ Syntax (Toggle Plain Text)
cout <<"2.What percentage of the ticket revenue goes to administrative costs?: "; cin >> percentticket;
percent = percentticket / 100;
But again without having an int variable that totals up the actual revenue from ticket sales, the above is pointless.
•
•
•
•
C++ Syntax (Toggle Plain Text)
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
•
•
Join Date: Mar 2008
Posts: 61
Reputation:
Solved Threads: 0
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
using namespace std;
int main()
{
int ticketssold, percentticket, moneyprizes, ticketstotal;
string charity;
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 << 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.
•
•
•
•
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.
C++ Syntax (Toggle Plain Text)
cout << percentticket/100. * ticketstotal << endl;
Remember to put a decimal point behind the 100 so that the resultant value becomes a floating point instead of an integer.
Founder of :
Lexel Technologies Pte Ltd - SMS (TXT) Marketing software solution
My Blogs: Gooner's Sanctuary
Pet Directory and Forum: FurryTale.net
Lexel Technologies Pte Ltd - SMS (TXT) Marketing software solution
My Blogs: Gooner's Sanctuary
Pet Directory and Forum: FurryTale.net
•
•
Join Date: Mar 2008
Posts: 61
Reputation:
Solved Threads: 0
alright so little by little im completing this program.
heres my updated code
now im having issues on calculating these things
Amount 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
?????
heres my updated code
C++ Syntax (Toggle Plain Text)
#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 things
Amount 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
?????
•
•
•
•
now im having issues on calculating these things
Amount deducted for prize money: $ 15000.00
Balance raised for charitable fund: $ 230000.00
That's because you are using integers. Alright, put a decimal point behind the number "5" and magic will appears.
Founder of :
Lexel Technologies Pte Ltd - SMS (TXT) Marketing software solution
My Blogs: Gooner's Sanctuary
Pet Directory and Forum: FurryTale.net
Lexel Technologies Pte Ltd - SMS (TXT) Marketing software solution
My Blogs: Gooner's Sanctuary
Pet Directory and Forum: FurryTale.net
•
•
•
•
alright thanks Denniz
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.
This question is actually very straightforward, apart from the programming syntax, you should also understand the logic behind all these calculations. Understanding of logic doesn't need programming background.
Founder of :
Lexel Technologies Pte Ltd - SMS (TXT) Marketing software solution
My Blogs: Gooner's Sanctuary
Pet Directory and Forum: FurryTale.net
Lexel Technologies Pte Ltd - SMS (TXT) Marketing software solution
My Blogs: Gooner's Sanctuary
Pet Directory and Forum: FurryTale.net
![]() |
Other Threads in the C++ Forum
- Previous Thread: Intro to headers
- Next Thread: Input from file
| Thread Tools | Search this Thread |
api array arrays based beginner binary c++ c/c++ calculator char class classes code compile compiler console conversion count delete deploy desktop directshow dll download dynamic dynamiccharacterarray encryption error file forms fstream function functions game getline givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory news number output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg string strings struct temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets







