C++ Help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JurseyRider734
    lil j the bad b-word
    • Aug 2003
    • 7506

    #1

    C++ Help

    I need someone who's good at C++ to maybe make me this code. It's probably really basic for someone who's knowledgable about it but I got really confused. I can just check this thread and copy and paste it into there tomorrow.

    Programming Project: ProfitMargin

    To make a profit, a local store marks up the prices of its items by a certain percentage. Write a C++ program that reads the original price of the item sold, the percentage of the marked-up price, and the sales tax rate. The program then outputs the original price of the item, the percentage of the mark-up, the store's selling price of the item, the sales tax rate, the sales tax, and the final price of the item. (The final price of the item is the selling price plus the sales tax.


    Thanks >_>
    Originally posted by Arch0wl
    I'd better be considering I own roughly six textbooks on logic and have taken courses involving its extensive use

    Originally posted by Afrobean
    Originally Posted by JurseyRider734
    the fact that you're resorting to threatening physical violence says a lot anyway.
    Just that you're a piece of shit who can't see reason and instead deserves a fucking beating.
  • lightdarkness
    Summer!!
    • Jul 2003
    • 11308

    #2
    RE: C++ Help

    That isn't C++, that's math

    If you're familiar with how to cin and cout stuff, it's really all about knowing what kind of math is involved.

    I can't remember how variables are stored in C++, but my first suggestion for you is to take out a sheet of paper, and do one practice input.

    Comment

    • QreepyBORIS
      FFR Player
      • Feb 2003
      • 7454

      #3
      RE: C++ Help

      You can use Doubles/Floats and <iomanip.h>'s set preceision function, if you've learned it. The math involved is really easy, unless you have a weird taxation percent in New Jersey.

      Signature subject to change.

      THE ZERRRRRG.

      Comment

      • JurseyRider734
        lil j the bad b-word
        • Aug 2003
        • 7506

        #4
        RE: C++ Help

        what.
        Originally posted by Arch0wl
        I'd better be considering I own roughly six textbooks on logic and have taken courses involving its extensive use

        Originally posted by Afrobean
        Originally Posted by JurseyRider734
        the fact that you're resorting to threatening physical violence says a lot anyway.
        Just that you're a piece of shit who can't see reason and instead deserves a fucking beating.

        Comment

        • soccr743
          FFR Player
          • Dec 2003
          • 549

          #5
          Re: C++ Help

          Originally posted by JurseyRider734
          To make a profit, a local store marks up the prices of its items by a certain percentage. Write a C++ program that reads the original price of the item sold, the percentage of the marked-up price, and the sales tax rate. The program then outputs the original price of the item, the percentage of the mark-up, the store's selling price of the item, the sales tax rate, the sales tax, and the final price of the item. (The final price of the item is the selling price plus the sales tax.
          First off, are you reading this from a file? Or from the command prompt...

          Secondly, you need to just know math. Just use the variable type "float" for the variable in this case.

          Thirdly, you need to know how to convert from a string or char* to a floating point number. I use my own String class library, so I am not sure if the standard library contains a method for converting strings to integers or floats.

          -----Soccr743-----

          Comment

          • QreepyBORIS
            FFR Player
            • Feb 2003
            • 7454

            #6
            RE: Re: C++ Help

            Why/how on Earth would you go from char/string to a float?

            Signature subject to change.

            THE ZERRRRRG.

            Comment

            • JurseyRider734
              lil j the bad b-word
              • Aug 2003
              • 7506

              #7
              RE: Re: C++ Help

              Keep in mind i've been in C++ for a week, and I have no fucking clue what you're talking about. It doesn't matter what the numbers are, i'm just confused with what to put.

              The only reason i'm posting is because i'm a day behind in my class. So while everyone is on addictinggames, i'm sitting there confused with this goddamn thing.
              Originally posted by Arch0wl
              I'd better be considering I own roughly six textbooks on logic and have taken courses involving its extensive use

              Originally posted by Afrobean
              Originally Posted by JurseyRider734
              the fact that you're resorting to threatening physical violence says a lot anyway.
              Just that you're a piece of shit who can't see reason and instead deserves a fucking beating.

              Comment

              • soccr743
                FFR Player
                • Dec 2003
                • 549

                #8
                RE: Re: C++ Help

                Qreepy, you read from the console into the buffer which is in char* format... Then, you would need to convert that to a float in order to use it in calculations.

                I would talk with you on AIM about it Eva, but I have a boatload of homework and you bloxed meh

                -----Soccr743-----

                Comment

                • chickendude
                  Away from Computer
                  FFR Simfile Author
                  • Sep 2003
                  • 1901

                  #9
                  RE: C++ Help

                  I can do C, but I'm guessing its mostly the same except for minor syntactical stuff <_<

                  Code:
                  main&#40;&#41;
                  &#123;
                   float oprice, taxrate, markup,fprice,sprice,tax;
                  
                   printf&#40;"print the original price, tax rate percentage, and markup percentage"&#41;
                   scanf&#40;"%f %f %f",&oprice,&taxrate,&markup&#41;;
                  
                   sprice = oprice * &#40;1 + &#40;markup/100&#41; &#41;;
                   taxprice = sprice * &#40;1 + taxrate/100&#41;;
                   fprice = sprice + taxprice;
                  
                   printf&#40;"original price is %f \n markup is %f \n taxrate is %f \n",oprice,markup,taxrate"&#41;
                   printf&#40;"store price is %f \n sales tax is %f \n final price is %f\n",sprice,tax,fprice"&#41;;
                  &#125;
                  now just change the printfs into couts and scanf into a cin and you win
                  I don't know the syntax for couts and cin >_<
                  would someone like to tell me
                  Is it just the same but with << >> instead of () ?

                  EDIT:
                  PS, in C to go from string to int its
                  stoi(insertstringhere)
                  and you have to #include <stdlib.h>
                  and stof for string to float
                  ftoi, itof, they're all there <_< itos ftos <_<

                  Comment

                  • JurseyRider734
                    lil j the bad b-word
                    • Aug 2003
                    • 7506

                    #10
                    RE: C++ Help

                    That's COMPLETELY different.

                    Soccr, I unblocked you a while ago rofl wtg
                    Originally posted by Arch0wl
                    I'd better be considering I own roughly six textbooks on logic and have taken courses involving its extensive use

                    Originally posted by Afrobean
                    Originally Posted by JurseyRider734
                    the fact that you're resorting to threatening physical violence says a lot anyway.
                    Just that you're a piece of shit who can't see reason and instead deserves a fucking beating.

                    Comment

                    • chickendude
                      Away from Computer
                      FFR Simfile Author
                      • Sep 2003
                      • 1901

                      #11
                      RE: C++ Help

                      after getting some rudimentary C++ syntax help <_<

                      Code:
                      #include <iostream>
                      main&#40;&#41;
                      &#123;
                       float oprice, taxrate, markup,fprice,sprice,tax;
                      
                       cout<<"print the original price, tax rate percentage, and markup percentage";
                       cin>>oprice>>taxrate>>markup;
                      
                       sprice = oprice * &#40;1 + &#40;markup/100&#41; &#41;;
                       taxprice = sprice * &#40;1 + taxrate/100&#41;;
                       fprice = sprice + taxprice;
                      
                       cout<<"original price is",oprice;
                       cout<<"markup is",markup;
                       cout<<"taxrate is",taxrate;
                       cout<<"store price is",sprice;
                       cout<<"sales tax is",tax;
                       cout<<"final price is",fprice;
                      &#125;
                      I don't know whether you need to do int main or void main
                      and also I don't know what lib to include
                      is it #include <iostream> ?

                      this should be slightly less way different, I hope <_<

                      EDIT: Edited in iostream

                      Comment

                      • talisman
                        Resident Penguin
                        FFR Simfile Author
                        • May 2003
                        • 4598

                        #12
                        RE: C++ Help

                        yeah it's <iostream>

                        chicken's program should work.

                        Comment

                        • soccr743
                          FFR Player
                          • Dec 2003
                          • 549

                          #13
                          RE: C++ Help

                          I question this line:

                          "cin>>oprice,taxrate,markup;"

                          Seems as though it should be this:

                          "cin >> oprice >> taxrate >> markup;"

                          But again, I don't do much work with the console.

                          -----Soccr743-----

                          Comment

                          • chickendude
                            Away from Computer
                            FFR Simfile Author
                            • Sep 2003
                            • 1901

                            #14
                            RE: C++ Help

                            Well I don't either, if you're right, then I'll edit it in, so does anyone else know?

                            EDIT:
                            I just realized that was soccr speaking so uh <_< I'll go ahead and change that

                            Comment

                            • soccr743
                              FFR Player
                              • Dec 2003
                              • 549

                              #15
                              RE: C++ Help

                              Hell, me speaking does not mean I am right... Especially when it comes to console programming. I really only did this stuff like a year ago when I first started and have since then moved from SDL to DirectX.

                              -----Soccr743-----

                              Comment

                              Working...