I need help with a program.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sujishishou
    FFR Player
    • Oct 2005
    • 183

    #1

    I need help with a program.

    O K I have to do a project for my principles of computer programming class. My teacher is busy so I can't ask him anything right now. I also just got into C++ so I am a bit lost.

    Anyways, what I have to do is write a program that accepts any integer between 1000 and 3000 and outputs its Roman numeral. ex. 1543 = MDXLIII

    I have no clue how to go about doing that so I will greatly appreciate if someone would help a guy out.
  • RandomPscho
    FFR Player
    • Jun 2006
    • 504

    #2
    Re: I need help with a program.

    I will give you some psuedocode Sorry my roman numeral knowledge is incomplete
    Code:
    do{
          prompt and get user input
    } while(the users number is not 1000-3000)
    
    if the number entered / 1000 is not 0
         output M 
         number entered minus 1000
         check if C needs to go before it and how many
         repeat
    if number entered /500 is not 0
        output D
        number entered minus 1000
         Check if C needs to go before it
        repeat
    ........ etc.

    Questions just ask.
    EDIT: I think I might make it, but it is a little hard Rusty in c++.
    Here is a source: http://www.planet-source-code.com/vb...=9705&lngWId=3
    Last edited by RandomPscho; 03-2-2007, 01:51 PM.

    Comment

    • sujishishou
      FFR Player
      • Oct 2005
      • 183

      #3
      Re: I need help with a program.

      Hey thanks a lot!
      I should be able to make the program to work now.
      I'll paste the code in here so you can look at it when I am finished.

      edit: It did not help as much as I hoped.
      If anyone can tell me how I can output a string of symbols like say:
      for M you take the entered number and divide if by 1000
      M = number / 1000. Then say you entered 2000. One gets 2.
      How do I make it so that the program outputs 2 M's when you find 2 for M?
      Last edited by sujishishou; 03-5-2007, 01:36 PM.

      Comment

      • JsPapp26
        FFR Veteran
        • Oct 2004
        • 96

        #4
        Re: I need help with a program.

        I know almost nothing in C++, but I know a bit about basics of programming.


        But anyway, if you only have to do 1000 - 3000, I would make three different if statements, like this (i probably have the wrong command because I don't know any commands in C++):

        if (x / 1000 = 1) {
        print "M";
        }
        if (x / 1000 = 2) {
        print "MM";
        }
        if (x / 1000 = 3) {
        print "MMM";
        }

        But that probably wouldn't work, because you wouldn't get any numbers between those.... I don't know... Just try stuff.
        Last edited by JsPapp26; 03-11-2007, 07:28 PM.
        Originally posted by Synthlight
        We need to take a better photo and make a t-shirt out of that. That is awesome.

        Comment

        Working...