Help?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Allan

    Help?

    I need help writing a program. I need to convert temps. from fahernheit to
    celsius. This is what I have. Can someone help?

    // This program is for converting temperatures recorded in Fahrenheit to
    Celsius.

    #include <iostream>

    using std::cout; //program uses cout
    using std::cin; //program uses cin

    // Beginning main program

    int main()

    {
    int outputcelsius
    int userinputfahren heit

    cout <<Enter a Temperature in Fahrenheit\n";
    cin >>

    outputcelsius = (userinputfahre nheit-32)*(5/9)

    return 0;

    }


  • Kevin Goodsell

    #2
    Re: Help?

    Allan wrote:
    [color=blue]
    > I need help writing a program. I need to convert temps. from fahernheit to
    > celsius. This is what I have. Can someone help?[/color]

    Please use descriptive subject lines. You are much more likely to get
    help that way.

    As for your problem, you failed to ask a C++ question, so the only C++
    answer I am able to give is, "Design an algorithm. Implement it in C++."
    [color=blue]
    >
    > // This program is for converting temperatures recorded in Fahrenheit to
    > Celsius.
    >
    > #include <iostream>
    >
    > using std::cout; //program uses cout
    > using std::cin; //program uses cin
    >
    > // Beginning main program
    >
    > int main()
    >
    > {
    > int outputcelsius
    > int userinputfahren heit
    >
    > cout <<Enter a Temperature in Fahrenheit\n";
    > cin >>
    >
    > outputcelsius = (userinputfahre nheit-32)*(5/9)[/color]

    Did you really want to multiply by 0? 5/9 == 0. If you don't know why,
    read up on integer math in your C++ book.
    [color=blue]
    >
    > return 0;
    >
    > }
    >
    >[/color]

    -Kevin
    --
    My email address is valid, but changes periodically.
    To contact me please use the address from a recent posting.

    Comment

    • Gianni Mariani

      #3
      Re: Help?

      Allan wrote:[color=blue]
      > I need help writing a program. I need to convert temps. from fahernheit to
      > celsius. This is what I have. Can someone help?
      >
      > // This program is for converting temperatures recorded in Fahrenheit to
      > Celsius.
      >
      > #include <iostream>
      >
      > using std::cout; //program uses cout
      > using std::cin; //program uses cin
      >
      > // Beginning main program
      >
      > int main()
      >
      > {
      > int outputcelsius
      > int userinputfahren heit
      >
      > cout <<Enter a Temperature in Fahrenheit\n";
      > cin >>
      >
      > outputcelsius = (userinputfahre nheit-32)*(5/9)
      >
      > return 0;
      >
      > }[/color]

      What were the compiler errors ?

      Here are a couple of hints.

      5/9 is not well represented by an "int" type. You might want to try a
      type that represents fractional quantities.

      the line "cin >>" is probably a typo, you probably meant

      "cin >> variable".

      The outputcelsius is computed but you never show anyone, the program
      exits and all the hard work about computing the value is lost. What do
      you want to do with the result ?

      G

      Comment

      • Jacek Dziedzic

        #4
        Re: Help?

        .... plus you're definitely missing some semicolons here and there
        and an opening quote on the "cout" line.

        - J.


        Comment

        • Kevin Goodsell

          #5
          Re: Help?

          Jacek Dziedzic wrote:
          [color=blue]
          > ... plus you're definitely missing some semicolons here and there
          > and an opening quote on the "cout" line.
          >[/color]

          To whom are you referring? Please quote some context when replying so we
          know what you are replying to.

          -Kevin
          --
          My email address is valid, but changes periodically.
          To contact me please use the address from a recent posting.

          Comment

          • Jacek Dziedzic

            #6
            Re: Help? -&gt; [OT] quoting properly

            "Kevin Goodsell" <usenet1.spamfr ee.fusion@never box.com> wrote
            in message news:yyobb.1299 $vS.651@newsrea d3.news.pas.ear thlink.net...[color=blue]
            > Jacek Dziedzic wrote:
            >[color=green]
            > > ... plus you're definitely missing some semicolons here and
            > > there
            > > and an opening quote on the "cout" line.
            > >[/color]
            >
            > To whom are you referring? Please quote some context when
            > replying so we know what you are replying to.[/color]

            All right, all right. My newsserver somehow missed the
            OP's post, hence my reply to a reply, but I hoped the OP
            would use the "apply logic" principle and realize I was
            talking to him. I'm pretty sure you did too.

            BTW, I realize that some people have an allergic reaction
            to top-posting or overquoting, etc. but I thought that
            no-quoting was perfectly OK when I had only a single
            sentence to say. Might reconsider that though.

            - J.


            Comment

            • Kevin Goodsell

              #7
              Re: Help? -&gt; [OT] quoting properly

              Jacek Dziedzic wrote:
              [color=blue]
              >
              > All right, all right. My newsserver somehow missed the
              > OP's post, hence my reply to a reply,[/color]

              There's nothing wrong with that, but if you copy & paste a bit to give
              context to your reply, it helps avoid confusion.
              [color=blue]
              > but I hoped the OP
              > would use the "apply logic" principle and realize I was
              > talking to him. I'm pretty sure you did too.
              >
              > BTW, I realize that some people have an allergic reaction
              > to top-posting or overquoting, etc. but I thought that
              > no-quoting was perfectly OK when I had only a single
              > sentence to say. Might reconsider that though.[/color]

              A rule of thumb is to assume that people reading your message 1) might
              not have seen other messages in the thread yet, and 2) have news clients
              that don't thread messages. Both of these will be true in some cases.

              -Kevin
              --
              My email address is valid, but changes periodically.
              To contact me please use the address from a recent posting.

              Comment

              Working...