Results 1 to 8 of 8
  1. #1
    antidup is offline Member
    Join Date
    Aug 2011
    Posts
    4
    Rep Power
    0

    Default 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. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,817
    Rep Power
    19

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

    And?
    Your question is?

  3. #3
    sehudson's Avatar
    sehudson is offline Senior Member
    Join Date
    Mar 2010
    Posts
    354
    Rep Power
    5

    Default 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. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,352
    Blog Entries
    7
    Rep Power
    20

    Default 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
    cenosillicaphobia: the fear for an empty beer glass

  5. #5
    sehudson's Avatar
    sehudson is offline Senior Member
    Join Date
    Mar 2010
    Posts
    354
    Rep Power
    5

    Default 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. #6
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,352
    Blog Entries
    7
    Rep Power
    20

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

    Quote Originally Posted by sehudson View Post
    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
    cenosillicaphobia: the fear for an empty beer glass

  7. #7
    sehudson's Avatar
    sehudson is offline Senior Member
    Join Date
    Mar 2010
    Posts
    354
    Rep Power
    5

    Default 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. #8
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,352
    Blog Entries
    7
    Rep Power
    20

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

    Quote Originally Posted by sehudson View Post
    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
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. round to two decimal places
    By javaMike in forum New To Java
    Replies: 3
    Last Post: 12-24-2011, 02:01 AM
  2. 3 Decimal Places
    By benhawk in forum New To Java
    Replies: 7
    Last Post: 11-02-2010, 09:28 PM
  3. 2 decimal places needed
    By lala in forum New To Java
    Replies: 5
    Last Post: 10-27-2010, 08:13 PM
  4. [SOLVED] Decimal Places - Is this possible?
    By dbashby in forum New To Java
    Replies: 4
    Last Post: 04-08-2009, 07:49 PM
  5. Capping decimal places
    By Rageagainst20 in forum New To Java
    Replies: 1
    Last Post: 12-20-2007, 09:28 PM

Posting Permissions

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