Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Algorithms
  4. convert Metric to English and English to Metric using pseudocod

convert Metric to English and English to Metric using pseudocod

Scheduled Pinned Locked Moved Algorithms
designalgorithmshelptutorial
80 Posts 11 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • 1 123 0

    xcom2001 wrote:

    This is my first programming class and I need help. I am being asked to design an algorithm for a converter that converts units in Metric to English and vice versa. The choice of code is pseudocode. Please if someone would at least write an example for me of this code I could study it and use it as a teaching aide to help me understand how this works.

    Here is an example of one of the routines you will need:

    To convert some centigrade degrees to some fahrenheit degrees:
    Put the centigrade degrees into the fahrenheit degrees.
    Multiply the fahrenheit degrees by 9.
    Divide the fahrenheit degrees by 5.
    Add 32 to the fahrenheit degrees.

    Incidently, though most people would consider this "pseudocode", it is actually Plain English code and can be compiled and run using the Osmosian Order's Plain English development system (which was written entirely in Plain English).

    S Offline
    S Offline
    Stephen Hewitt
    wrote on last edited by
    #10

    Or more succinctly:  f = 9/5*c+32 Where "c" is degrees centigrade and "f" is degrees in fahrenheit. This is clearer in every way. -- modified at 20:39 Sunday 10th December, 2006 Not only is it clearer but also more useful. Using the basic rules of algebra I can derive the f->c conversion as follows:  f = 9/5*c+32  f-32 = 9/5*c  (f-32)*5 = 9*c  (f-32)*5/9 = c   So  c = (f-32)*5/9

    Steve

    1 1 Reply Last reply
    0
    • 1 123 0

      Chris Maunder wrote:

      I just want you, as I have asked many times before, to cease using these forums for self promotion.

      Self promotion, as we've discussed before, is the wrong term. As I've said many times before, what we're promoting is ideas - in this case, the ideas that (1) people naturally think, not in artificial languages, but in natural languages, of which pseudocode is a degenerate case; and (2) since pseudocode-like languages can be compiled and run and used to develop even low-level programs like compilers and high-level programs like page editors, we should all reconsider the role of artifical/natural languages in computer programming. The original poster is just starting out and we wouldn't want this person to be denied exposure to all aspects of "state of the art", now would we? Our Plain English development system is nothing but a "proof of concept" that we offer, here and elsewhere, to eliminate unnecessary responses claiming our ideas are "nice, but impractical". That's all. The product is not important except as a working manifestation of the ideas behind it.

      S Offline
      S Offline
      Stephen Hewitt
      wrote on last edited by
      #11

      The Grand Negus wrote:

      Self promotion, as we've discussed before, is the wrong term.

      Actually, I think it's pretty much spot on. Don't get me wrong; I don't really care one way or the other if you use this forum for self promotion. Denying it is futile however. In general you only reply to questions which give you some "plausibile deniability".

      Steve

      1 1 Reply Last reply
      0
      • S Stephen Hewitt

        The Grand Negus wrote:

        Self promotion, as we've discussed before, is the wrong term.

        Actually, I think it's pretty much spot on. Don't get me wrong; I don't really care one way or the other if you use this forum for self promotion. Denying it is futile however. In general you only reply to questions which give you some "plausibile deniability".

        Steve

        1 Offline
        1 Offline
        123 0
        wrote on last edited by
        #12

        Stephen Hewitt wrote:

        In general you only reply to questions which give you some "plausibile deniability".

        Actually, I reply when the opportunity presents itself to promote - not myself - but one or more of several principles that lead to different ways of thinking about programming, and that, when applied, produce significantly different programs. Our Plain English development system is one example.

        P S 2 Replies Last reply
        0
        • S Stephen Hewitt

          Or more succinctly:  f = 9/5*c+32 Where "c" is degrees centigrade and "f" is degrees in fahrenheit. This is clearer in every way. -- modified at 20:39 Sunday 10th December, 2006 Not only is it clearer but also more useful. Using the basic rules of algebra I can derive the f->c conversion as follows:  f = 9/5*c+32  f-32 = 9/5*c  (f-32)*5 = 9*c  (f-32)*5/9 = c   So  c = (f-32)*5/9

          Steve

          1 Offline
          1 Offline
          123 0
          wrote on last edited by
          #13

          Stephen Hewitt wrote:

          Or more succinctly: f = 9/5*c+32 Where "c" is degrees centigrade and "f" is degrees in fahrenheit.

          And what language is that last line?

          Stephen Hewitt wrote:

          Not only is it clearer but also more useful. Using the basic rules of algebre I can derive the f->c conversion as follows: f = 9/5*c+32 f-32 = 9/5*c (f-32)*5 = 9*c (f-32)*5/9 = c So c = (f-32)*5/9

          Let me make this perfectly clear, at least between you and I, once and for all. We're not saying that algebra is useless, or that algebraic notation is less appropriate than Plain English for certain specific tasks. We're saying that algebraic notation is more easily thought of as a sub-language of English rather than the reverse. We're saying that an intelligent machine should understand both; specifically, it should understand the sub-language in the context of the larger, natural language - exactly as you have used both "languages" in the quotations above. The letters "c" and "f" can be appropriate abbreviations, in certain contexts, but only if their meanings are clearly defined at a higher, more descriptive level. The reason we are emphasizing (at this time) the natural language aspect is that computers already know how to parse, manipulate, and otherwise process algebraic notation - but they don't know how to deal with natural languages with the same level of expertise. And because most programmers are unaware of the amazing power and flexibility that natural languages possess. C'mon - off the top of your head, would you think that an efficient native-code-generating compiler could be conveniently written in English?

          S P D U 4 Replies Last reply
          0
          • C Chris Maunder

            I will repeat: Enough is enough.

            cheers, Chris Maunder

            CodeProject.com : C++ MVP

            P Offline
            P Offline
            Paul Conrad
            wrote on last edited by
            #14

            Chris Maunder wrote:

            I will repeat: Enough is enough.

            :laugh::laugh::laugh:


            If you try to write that in English, I might be able to understand more than a fraction of it. - Guffa

            1 Reply Last reply
            0
            • 1 123 0

              Chris Maunder wrote:

              I just want you, as I have asked many times before, to cease using these forums for self promotion.

              Self promotion, as we've discussed before, is the wrong term. As I've said many times before, what we're promoting is ideas - in this case, the ideas that (1) people naturally think, not in artificial languages, but in natural languages, of which pseudocode is a degenerate case; and (2) since pseudocode-like languages can be compiled and run and used to develop even low-level programs like compilers and high-level programs like page editors, we should all reconsider the role of artifical/natural languages in computer programming. The original poster is just starting out and we wouldn't want this person to be denied exposure to all aspects of "state of the art", now would we? Our Plain English development system is nothing but a "proof of concept" that we offer, here and elsewhere, to eliminate unnecessary responses claiming our ideas are "nice, but impractical". That's all. The product is not important except as a working manifestation of the ideas behind it.

              P Offline
              P Offline
              Paul Conrad
              wrote on last edited by
              #15

              The Grand Negus wrote:

              Our Plain English development system

              Haven't you taken the hint that most people here are not interested in Plain English? This site is a Microsoft technologies based site.


              If you try to write that in English, I might be able to understand more than a fraction of it. - Guffa

              1 1 Reply Last reply
              0
              • 1 123 0

                Stephen Hewitt wrote:

                Or more succinctly: f = 9/5*c+32 Where "c" is degrees centigrade and "f" is degrees in fahrenheit.

                And what language is that last line?

                Stephen Hewitt wrote:

                Not only is it clearer but also more useful. Using the basic rules of algebre I can derive the f->c conversion as follows: f = 9/5*c+32 f-32 = 9/5*c (f-32)*5 = 9*c (f-32)*5/9 = c So c = (f-32)*5/9

                Let me make this perfectly clear, at least between you and I, once and for all. We're not saying that algebra is useless, or that algebraic notation is less appropriate than Plain English for certain specific tasks. We're saying that algebraic notation is more easily thought of as a sub-language of English rather than the reverse. We're saying that an intelligent machine should understand both; specifically, it should understand the sub-language in the context of the larger, natural language - exactly as you have used both "languages" in the quotations above. The letters "c" and "f" can be appropriate abbreviations, in certain contexts, but only if their meanings are clearly defined at a higher, more descriptive level. The reason we are emphasizing (at this time) the natural language aspect is that computers already know how to parse, manipulate, and otherwise process algebraic notation - but they don't know how to deal with natural languages with the same level of expertise. And because most programmers are unaware of the amazing power and flexibility that natural languages possess. C'mon - off the top of your head, would you think that an efficient native-code-generating compiler could be conveniently written in English?

                P Offline
                P Offline
                Paul Conrad
                wrote on last edited by
                #16

                The Grand Negus wrote:

                algebraic notation is less appropriate than Plain English for certain specific tasks

                Isn't it possible for you to have any kind of discussion in these forums without uttering "Plain English"? I am starting to think it is not possible...


                If you try to write that in English, I might be able to understand more than a fraction of it. - Guffa

                1 U 2 Replies Last reply
                0
                • 1 123 0

                  Stephen Hewitt wrote:

                  Or more succinctly: f = 9/5*c+32 Where "c" is degrees centigrade and "f" is degrees in fahrenheit.

                  And what language is that last line?

                  Stephen Hewitt wrote:

                  Not only is it clearer but also more useful. Using the basic rules of algebre I can derive the f->c conversion as follows: f = 9/5*c+32 f-32 = 9/5*c (f-32)*5 = 9*c (f-32)*5/9 = c So c = (f-32)*5/9

                  Let me make this perfectly clear, at least between you and I, once and for all. We're not saying that algebra is useless, or that algebraic notation is less appropriate than Plain English for certain specific tasks. We're saying that algebraic notation is more easily thought of as a sub-language of English rather than the reverse. We're saying that an intelligent machine should understand both; specifically, it should understand the sub-language in the context of the larger, natural language - exactly as you have used both "languages" in the quotations above. The letters "c" and "f" can be appropriate abbreviations, in certain contexts, but only if their meanings are clearly defined at a higher, more descriptive level. The reason we are emphasizing (at this time) the natural language aspect is that computers already know how to parse, manipulate, and otherwise process algebraic notation - but they don't know how to deal with natural languages with the same level of expertise. And because most programmers are unaware of the amazing power and flexibility that natural languages possess. C'mon - off the top of your head, would you think that an efficient native-code-generating compiler could be conveniently written in English?

                  S Offline
                  S Offline
                  Stephen Hewitt
                  wrote on last edited by
                  #17

                  The Grand Negus wrote:

                  And what language is that last line?

                  I've got nothing against English; my gripe is with the use of English in an inappropriate context.

                  The Grand Negus wrote:

                  We're not saying that algebra is useless, or that algebraic notation is less appropriate than Plain English for certain specific tasks.

                  I agree with this sentiment. However, going back to the point I made above, a formula with some definitions in English as I gave above is a much better way to present the c->f conversion algorithm than English. In short, I contend that your example was a bad example of the merits of plain English.

                  Steve

                  1 U 2 Replies Last reply
                  0
                  • 1 123 0

                    Stephen Hewitt wrote:

                    In general you only reply to questions which give you some "plausibile deniability".

                    Actually, I reply when the opportunity presents itself to promote - not myself - but one or more of several principles that lead to different ways of thinking about programming, and that, when applied, produce significantly different programs. Our Plain English development system is one example.

                    P Offline
                    P Offline
                    Paul Conrad
                    wrote on last edited by
                    #18

                    The Grand Negus wrote:

                    Our Plain English development system is one example.

                    :|:zzz:


                    If you try to write that in English, I might be able to understand more than a fraction of it. - Guffa

                    1 Reply Last reply
                    0
                    • S Stephen Hewitt

                      The Grand Negus wrote:

                      And what language is that last line?

                      I've got nothing against English; my gripe is with the use of English in an inappropriate context.

                      The Grand Negus wrote:

                      We're not saying that algebra is useless, or that algebraic notation is less appropriate than Plain English for certain specific tasks.

                      I agree with this sentiment. However, going back to the point I made above, a formula with some definitions in English as I gave above is a much better way to present the c->f conversion algorithm than English. In short, I contend that your example was a bad example of the merits of plain English.

                      Steve

                      1 Offline
                      1 Offline
                      123 0
                      wrote on last edited by
                      #19

                      Stephen Hewitt wrote:

                      In short, I contend that your example was a bad example of the merits of plain English.

                      Agreed. Mathematical relations are a weak point in every natural language; that's why things like algebraic notation are invented in the first place. But I didn't get the choose the example here - the problem assigned by the instructor was clearly math-centric. Nevertheless, I'm quite sure that a complete solution to the given problem - including the interface, etc - would include a much smaller percentage of formulaic matter and would therefore benefit from the "compiled pseudocode" I recommended. It's not unlike a MIDI music machine I programmed years ago on and Apple II. There were certain routines that, for performance, had to be written in assembler. But the bulk of the program was much more easily written, tested, modified, and perfected in Applesoft Basic (a more English-like language). Besides, formulaic languages reach their "limits" very quickly (no pun intended). Consider, for example, this natural language description of an object:

                      a two-inch aluminum cube with a quarter-inch spherical void at its center

                      What's the formula for that? And for the other zillion things that can be easily described in half a sentence but that nevertheless defy mathematical description?

                      S D U 3 Replies Last reply
                      0
                      • P Paul Conrad

                        The Grand Negus wrote:

                        Our Plain English development system

                        Haven't you taken the hint that most people here are not interested in Plain English? This site is a Microsoft technologies based site.


                        If you try to write that in English, I might be able to understand more than a fraction of it. - Guffa

                        1 Offline
                        1 Offline
                        123 0
                        wrote on last edited by
                        #20

                        PaulC1972 wrote:

                        Haven't you taken the hint that most people here are not interested in Plain English?

                        Define "most". Supply verifiable numbers to support your definition.

                        P 1 Reply Last reply
                        0
                        • P Paul Conrad

                          The Grand Negus wrote:

                          algebraic notation is less appropriate than Plain English for certain specific tasks

                          Isn't it possible for you to have any kind of discussion in these forums without uttering "Plain English"? I am starting to think it is not possible...


                          If you try to write that in English, I might be able to understand more than a fraction of it. - Guffa

                          1 Offline
                          1 Offline
                          123 0
                          wrote on last edited by
                          #21

                          PaulC1972 wrote:

                          Isn't it possible for you to have any kind of discussion in these forums without uttering "Plain English"? I am starting to think it is not possible...

                          Actually, I've discussed many different things here. This very thread contains a reference to a post I made today regarding Latex where Plain English is not mentioned at all. But we came here specifically to discuss issues illustrated in our Plain English development system, and so it is not surprising that most of our posts address those same issues. We're not here to "socialize". We're on a mission...

                          P U 2 Replies Last reply
                          0
                          • 1 123 0

                            PaulC1972 wrote:

                            Haven't you taken the hint that most people here are not interested in Plain English?

                            Define "most". Supply verifiable numbers to support your definition.

                            P Offline
                            P Offline
                            Paul Conrad
                            wrote on last edited by
                            #22

                            The Grand Negus wrote:

                            Supply verifiable numbers to support your definition.

                            That's not necessary, just look at the "nasty" replies you get :|


                            If you try to write that in English, I might be able to understand more than a fraction of it. - Guffa

                            1 1 Reply Last reply
                            0
                            • 1 123 0

                              Stephen Hewitt wrote:

                              In short, I contend that your example was a bad example of the merits of plain English.

                              Agreed. Mathematical relations are a weak point in every natural language; that's why things like algebraic notation are invented in the first place. But I didn't get the choose the example here - the problem assigned by the instructor was clearly math-centric. Nevertheless, I'm quite sure that a complete solution to the given problem - including the interface, etc - would include a much smaller percentage of formulaic matter and would therefore benefit from the "compiled pseudocode" I recommended. It's not unlike a MIDI music machine I programmed years ago on and Apple II. There were certain routines that, for performance, had to be written in assembler. But the bulk of the program was much more easily written, tested, modified, and perfected in Applesoft Basic (a more English-like language). Besides, formulaic languages reach their "limits" very quickly (no pun intended). Consider, for example, this natural language description of an object:

                              a two-inch aluminum cube with a quarter-inch spherical void at its center

                              What's the formula for that? And for the other zillion things that can be easily described in half a sentence but that nevertheless defy mathematical description?

                              S Offline
                              S Offline
                              Stephen Hewitt
                              wrote on last edited by
                              #23

                              I agree that English has its place; just not where you used it. It seems you concede this point so I won't go on about it.

                              The Grand Negus wrote:

                              a two-inch aluminum cube with a quarter-inch spherical void at its center What's the formula for that?

                              You could describe this mathematically in many ways but I agree that for many uses an English description or a diagram would be superior. However, if you wanted to figure the required volume of aluminum required a mathematical description would be preferable.

                              The Grand Negus wrote:

                              Besides, formulaic languages reach their "limits" very quickly (no pun intended).

                              I think that pun was intended:)

                              Steve

                              1 U 2 Replies Last reply
                              0
                              • 1 123 0

                                PaulC1972 wrote:

                                Isn't it possible for you to have any kind of discussion in these forums without uttering "Plain English"? I am starting to think it is not possible...

                                Actually, I've discussed many different things here. This very thread contains a reference to a post I made today regarding Latex where Plain English is not mentioned at all. But we came here specifically to discuss issues illustrated in our Plain English development system, and so it is not surprising that most of our posts address those same issues. We're not here to "socialize". We're on a mission...

                                P Offline
                                P Offline
                                Paul Conrad
                                wrote on last edited by
                                #24

                                The Grand Negus wrote:

                                We're not here to "socialize". We're on a mission...

                                Mission to annoy...


                                If you try to write that in English, I might be able to understand more than a fraction of it. - Guffa

                                U 1 Reply Last reply
                                0
                                • P Paul Conrad

                                  The Grand Negus wrote:

                                  Supply verifiable numbers to support your definition.

                                  That's not necessary, just look at the "nasty" replies you get :|


                                  If you try to write that in English, I might be able to understand more than a fraction of it. - Guffa

                                  1 Offline
                                  1 Offline
                                  123 0
                                  wrote on last edited by
                                  #25

                                  PaulC1972 wrote:

                                  That's not necessary, just look at the "nasty" replies you get

                                  But from how many of the larger community here? A handful of cranks do not a majority make. Besides, I don't say what I say because it's popular (or not). I say these things simply because I believe them to be true. In other words, even if I got three million nasty remarks on this forum, I'd still be compelled to say the same kind of things.

                                  P S 2 Replies Last reply
                                  0
                                  • 1 123 0

                                    PaulC1972 wrote:

                                    That's not necessary, just look at the "nasty" replies you get

                                    But from how many of the larger community here? A handful of cranks do not a majority make. Besides, I don't say what I say because it's popular (or not). I say these things simply because I believe them to be true. In other words, even if I got three million nasty remarks on this forum, I'd still be compelled to say the same kind of things.

                                    P Offline
                                    P Offline
                                    Paul Conrad
                                    wrote on last edited by
                                    #26

                                    The Grand Negus wrote:

                                    I say these things simply because I believe them

                                    That's fine and dandy, we all are entitled to it.


                                    If you try to write that in English, I might be able to understand more than a fraction of it. - Guffa

                                    1 Reply Last reply
                                    0
                                    • S Stephen Hewitt

                                      I agree that English has its place; just not where you used it. It seems you concede this point so I won't go on about it.

                                      The Grand Negus wrote:

                                      a two-inch aluminum cube with a quarter-inch spherical void at its center What's the formula for that?

                                      You could describe this mathematically in many ways but I agree that for many uses an English description or a diagram would be superior. However, if you wanted to figure the required volume of aluminum required a mathematical description would be preferable.

                                      The Grand Negus wrote:

                                      Besides, formulaic languages reach their "limits" very quickly (no pun intended).

                                      I think that pun was intended:)

                                      Steve

                                      1 Offline
                                      1 Offline
                                      123 0
                                      wrote on last edited by
                                      #27

                                      Stephen Hewitt wrote:

                                      However, if you wanted to figure the required volume of aluminum required a mathematical description would be preferable.

                                      Not necessarily. Recall the story of Henry Ford who, encountering one of his engineers feverishly working out the volume of an oddly-shaped fuel tank, simply filled the thing with water and poured the contents into a graduated cylinder. Point being, the "mathematical" approach is not always the most effective. And in our opinion, much less often than commonly assumed. Did you, for example, "calculate" your way to the store the other day, or did you use other methods of measurement, comparison, and decision making? When you reach for the mouse, do you have trigonometry, consciously or unconsciously, on your mind?

                                      S U 2 Replies Last reply
                                      0
                                      • 1 123 0

                                        Stephen Hewitt wrote:

                                        However, if you wanted to figure the required volume of aluminum required a mathematical description would be preferable.

                                        Not necessarily. Recall the story of Henry Ford who, encountering one of his engineers feverishly working out the volume of an oddly-shaped fuel tank, simply filled the thing with water and poured the contents into a graduated cylinder. Point being, the "mathematical" approach is not always the most effective. And in our opinion, much less often than commonly assumed. Did you, for example, "calculate" your way to the store the other day, or did you use other methods of measurement, comparison, and decision making? When you reach for the mouse, do you have trigonometry, consciously or unconsciously, on your mind?

                                        S Offline
                                        S Offline
                                        Stephen Hewitt
                                        wrote on last edited by
                                        #28

                                        The Grand Negus wrote:

                                        Not necessarily. Recall the story of Henry Ford who, encountering one of his engineers feverishly working out the volume of an oddly-shaped fuel tank, simply filled the thing with water and poured the contents into a graduated cylinder.

                                        I take your point but immersing an aluminum cube with a void in the center will measure the volume of the cube including the void. You would have to fill the void with fluid to figure out how much to subtract since I was after how much aluminum was required. Based on the description of the shape, to get access to the void I would have to drill a hole in the box. In this case the mathematical approach seems best.

                                        The Grand Negus wrote:

                                        Did you, for example, "calculate" your way to the store the other day, or did you use other methods of measurement, comparison, and decision making? When you reach for the mouse, do you have trigonometry, consciously or unconsciously, on your mind?

                                        Mainly memory but I can say little out what method my mind used internally.

                                        Steve

                                        1 U 2 Replies Last reply
                                        0
                                        • S Stephen Hewitt

                                          The Grand Negus wrote:

                                          Not necessarily. Recall the story of Henry Ford who, encountering one of his engineers feverishly working out the volume of an oddly-shaped fuel tank, simply filled the thing with water and poured the contents into a graduated cylinder.

                                          I take your point but immersing an aluminum cube with a void in the center will measure the volume of the cube including the void. You would have to fill the void with fluid to figure out how much to subtract since I was after how much aluminum was required. Based on the description of the shape, to get access to the void I would have to drill a hole in the box. In this case the mathematical approach seems best.

                                          The Grand Negus wrote:

                                          Did you, for example, "calculate" your way to the store the other day, or did you use other methods of measurement, comparison, and decision making? When you reach for the mouse, do you have trigonometry, consciously or unconsciously, on your mind?

                                          Mainly memory but I can say little out what method my mind used internally.

                                          Steve

                                          1 Offline
                                          1 Offline
                                          123 0
                                          wrote on last edited by
                                          #29

                                          Stephen Hewitt wrote:

                                          Mainly memory but I can say little about what method my mind used internally.

                                          But that is exactly what we're trying to figure out. And we not interested in "higher mathematics" at this point because we're convinced there are no higher mathematics going on in, say, a two-year-old's mind when he understands and properly responds to simple commands.

                                          S U 2 Replies Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups