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??

Recommended Answers

All 12 Replies

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?

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;


}

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.

#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
using namespace std;

int main()
{
	int ticketssold, percentticket, moneyprizes, ticketstotal;
	string charity;
	


	
	[B]cout <<"1.Number of tickets sold?: ";
	cin >> ticketssold;

	ticketstotal = 5.00 * ticketssold;[/B]
	


	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.

The total admin charges is calculated as follows:

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.

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 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

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.

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.

commented: thanks for all the help =] +1

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.

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.

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.

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?

You still don't get it.

It should be:

ticketstotal - moneyprizes - (ticketstotal * percentticket/100.)

ahhhh, thank you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.