# Thread: I am making a program that format the output with two decimal places..

1. Member
Join Date
Aug 2011
Posts
4
Rep Power
0

## I am making a program that format the output with two decimal places..

The manager of a football stadium wants you to write a program that calculates the total ticket after each game. There are four types of tickets--box, sideline, premium, and general admission, after each game, the data is stores in the file in the following form:
Ticket Price number Of Ticket Sold...
Sample data are shown below:
250 5750
100 28000
50 35700
25 18750
The first input indicates the box ticket price is 250 and that 5750 tickets were sold that price. Output the number of tickets sold and the total sale amount. Format your output with two decimal places..

2. Moderator
Join Date
Apr 2009
Posts
13,541
Rep Power
27

And?

3. ## Re: I am making a program that format the output with two decimal places..

I'm assuming the input is coming from a text file? Have you tried anything?

4. ## Re: I am making a program that format the output with two decimal places..

As far as I can see, all you have to do is append ".00" to the total ticket price (all the prices are ints and you can only sell an integer number of tickets, so the result is an int as well).

kind regards,

Jos

5. ## Re: I am making a program that format the output with two decimal places..

I was thinking the same thing since all the ticket prices are whole numbers, but I'm wondering if the input in the example:

250 5750
100 28000
50 35700
25 18750

was just an example of the ticket prices, and he may be presented with a ticket price of \$250.99 for instance, and the program has to be able to handle that too. That would be my guess. Obviously the tickets sold will be whole, but maybe the ticket prices that they are going to run the program against might be xx.xx(?)

6. ## Re: I am making a program that format the output with two decimal places..

Originally Posted by sehudson
I was thinking the same thing since all the ticket prices are whole numbers, but I'm wondering if the input in the example:

250 5750
100 28000
50 35700
25 18750

was just an example of the ticket prices, and he may be presented with a ticket price of \$250.99 for instance, and the program has to be able to handle that too. That would be my guess. Obviously the tickets sold will be whole, but maybe the ticket prices that they are going to run the program against might be xx.xx(?)
There's an old saying in the CS industry that says "don't solve what hasn't been asked for"; I don't see any indication in the OPs description, nor example, that those prices aren't supposed to be ints. They are not supposed to be quaternions either, so why bother ;-)

kind regards,

Jos

7. ## Re: I am making a program that format the output with two decimal places..

well, it does say that it's sample data in what was posted.
That on top of the fact that the program mentions formatting the output to two decimal places would seem like he should code for it. Why bother mentioning formatting something to 2 decimal places if its always going to be .00
Last edited by sehudson; 09-14-2011 at 03:00 PM.

8. ## Re: I am making a program that format the output with two decimal places..

Originally Posted by sehudson
well, it does say that it's sample data in what was posted.
That on top of the fact that the program mentions formatting the output to two decimal places would seem like he should code for it. Why bother mentioning formatting something to 2 decimal places if its always going to be .00
I was just playing devils' advocate trying to show that the OP was sloppy with the example; so why ignore complex numbers and/or quaternions? The example didn't mention them but the description didn't exlude them either ...

kind regards,

Jos

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•