a little help please

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Mar 2008
Posts: 61
Reputation: anbuninja is an unknown quantity at this point 
Solved Threads: 0
anbuninja anbuninja is offline Offline
Junior Poster in Training

a little help please

 
0
  #1
Oct 3rd, 2008
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??
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 3,819
Reputation: VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute 
Solved Threads: 501
Featured Poster
VernonDozier VernonDozier is offline Offline
Senior Poster

Re: a little help please

 
0
  #2
Oct 3rd, 2008
Originally Posted by anbuninja View Post
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?
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 61
Reputation: anbuninja is an unknown quantity at this point 
Solved Threads: 0
anbuninja anbuninja is offline Offline
Junior Poster in Training

Re: a little help please

 
0
  #3
Oct 3rd, 2008
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

  1. #include<iostream>
  2. #include<iomanip>
  3. #include<string>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. int ticketssold, percentticket, moneyprizes;
  9. string charity;
  10.  
  11. cout <<"1.Number of tickets sold?: ";
  12. cin >> ticketssold;
  13.  
  14.  
  15.  
  16. cout <<"2.What percentage of the ticket revenue goes to administrative costs?: ";
  17. cin >> percentticket;
  18.  
  19. cout <<"3.How much total money is distributed in prizes?: ";
  20. cin >> moneyprizes;
  21.  
  22. cin.ignore();
  23.  
  24. cout <<"4.What is the name of the charity?: ";
  25. getline(cin,charity);
  26.  
  27. cout << left <<"Charity:" << right << setw(50) << charity << endl;
  28. cout << left <<"Revenue generated from ticket sales:" << right
  29.  
  30.  
  31.  
  32. system("pause");
  33. return 0;
  34.  
  35.  
  36. }
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 55
Reputation: RayvenHawk is an unknown quantity at this point 
Solved Threads: 1
RayvenHawk RayvenHawk is offline Offline
Junior Poster in Training

Re: a little help please

 
0
  #4
Oct 3rd, 2008
Originally Posted by anbuninja View Post
hmmm im really stuck
First off I agree with VernonDozier, just divide your percentage value by 100 to get a decimal.

Originally Posted by anbuninja View Post
  1. #include<iostream>
  2. #include<iomanip>
  3. #include<string>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. int ticketssold, percentticket, moneyprizes;
  9. string charity;
  10.  
  11. cout <<"1.Number of tickets sold?: ";
  12. 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.

Originally Posted by anbuninja View Post
  1. cout <<"2.What percentage of the ticket revenue goes to administrative costs?: ";
  2. 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.

Originally Posted by anbuninja View Post
  1.  
  2. cout <<"3.How much total money is distributed in prizes?: ";
  3. cin >> moneyprizes;
  4.  
  5. cin.ignore();
  6.  
  7. cout <<"4.What is the name of the charity?: ";
  8. getline(cin,charity);
  9.  
  10. cout << left <<"Charity:" << right << setw(50) << charity << endl;
  11. 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.
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 61
Reputation: anbuninja is an unknown quantity at this point 
Solved Threads: 0
anbuninja anbuninja is offline Offline
Junior Poster in Training

Re: a little help please

 
0
  #5
Oct 3rd, 2008
 #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.
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 429
Reputation: Denniz is on a distinguished road 
Solved Threads: 15
Denniz's Avatar
Denniz Denniz is offline Offline
Posting Pro in Training

Re: a little help please

 
0
  #6
Oct 3rd, 2008
Originally Posted by anbuninja View Post
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.
The total admin charges is calculated as follows:

  1. 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.
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 61
Reputation: anbuninja is an unknown quantity at this point 
Solved Threads: 0
anbuninja anbuninja is offline Offline
Junior Poster in Training

Re: a little help please

 
0
  #7
Oct 5th, 2008
alright so little by little im completing this program.

heres my updated code

  1. #include<iostream>
  2. #include<iomanip>
  3. #include<cmath>
  4. #include<string>
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. int ticketssold, moneyprizes, ticketstotal;
  10. string charity;
  11. float percentticket;
  12.  
  13.  
  14.  
  15. cout <<"1.Number of tickets sold?: ";
  16. cin >> ticketssold;
  17.  
  18. ticketstotal = 5.00 * ticketssold;
  19.  
  20.  
  21.  
  22. cout <<"2.What percentage of the ticket revenue goes to administrative costs?: ";
  23. cin >> percentticket;
  24.  
  25.  
  26. cout <<"3.How much total money is distributed in prizes?: ";
  27. cin >> moneyprizes;
  28.  
  29. cin.ignore();
  30.  
  31. cout <<"4.What is the name of the charity?: ";
  32. getline(cin,charity);
  33.  
  34. cout <<"Charity:" << right << setw(55) << charity << endl;
  35.  
  36. cout <<"Revenue generated from ticket sales:" << right << fixed << setprecision(2) << setw(16) << '$'
  37. << ticketssold * 5 << endl;
  38.  
  39. cout <<"Amount deducted for administrative overhead:" << right << fixed << setprecision(2) << setw(8) << '$'
  40. << percentticket/100. * ticketstotal << endl;
  41.  
  42.  
  43.  
  44. system("pause");
  45. return 0;
  46.  
  47.  
  48. }

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

?????
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 429
Reputation: Denniz is on a distinguished road 
Solved Threads: 15
Denniz's Avatar
Denniz Denniz is offline Offline
Posting Pro in Training

Re: a little help please

 
1
  #8
Oct 5th, 2008
Originally Posted by anbuninja View Post
now im having issues on calculating these things
Amount deducted for prize money: $ 15000.00
Balance raised for charitable fund: $ 230000.00
What's the difficulty in calculating these two items? The first one is straight from the value the user entered, the second was just the total revenue deducting the admin fee & prize money.

Originally Posted by anbuninja View Post
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

?????
That's because you are using integers. Alright, put a decimal point behind the number "5" and magic will appears.
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 61
Reputation: anbuninja is an unknown quantity at this point 
Solved Threads: 0
anbuninja anbuninja is offline Offline
Junior Poster in Training

Re: a little help please

 
0
  #9
Oct 5th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 429
Reputation: Denniz is on a distinguished road 
Solved Threads: 15
Denniz's Avatar
Denniz Denniz is offline Offline
Posting Pro in Training

Re: a little help please

 
0
  #10
Oct 5th, 2008
Originally Posted by anbuninja View Post
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.
That's because you deducted the wrong thing. Instead of deducting the total admin overhead, you deducted the $2 admin fee!

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.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC