Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[C++] Fahrenheit To Celsius Converter

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
JakSplitter
Expert Cheater
Reputation: 0

Joined: 31 Aug 2006
Posts: 196

PostPosted: Thu Nov 15, 2007 7:44 pm    Post subject: [C++] Fahrenheit To Celsius Converter Reply with quote

Well, i recently picked up on C++ again so i decided to make a little Fahrenheit To Celsius Converter.


The Extension 'rar' was deactivated by an board admin, therefore this Attachment is not displayed.

Back to top
View user's profile Send private message AIM Address
CRISISxCupid
I post too much
Reputation: 1

Joined: 09 Jun 2007
Posts: 2256

PostPosted: Thu Nov 15, 2007 7:46 pm    Post subject: Reply with quote

Thank you Very Happy

I needed it for homework O.o

_________________
Back to top
View user's profile Send private message
JakSplitter
Expert Cheater
Reputation: 0

Joined: 31 Aug 2006
Posts: 196

PostPosted: Thu Nov 15, 2007 7:47 pm    Post subject: Reply with quote

Lol np.
Back to top
View user's profile Send private message AIM Address
MegaForum
Grandmaster Cheater
Reputation: 0

Joined: 20 Aug 2007
Posts: 558

PostPosted: Thu Nov 15, 2007 8:04 pm    Post subject: Reply with quote

These are very useful Very Happy . Good thing to start out on for practice.
Back to top
View user's profile Send private message
JakSplitter
Expert Cheater
Reputation: 0

Joined: 31 Aug 2006
Posts: 196

PostPosted: Thu Nov 15, 2007 8:15 pm    Post subject: Reply with quote

Lol thanks.
Back to top
View user's profile Send private message AIM Address
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Fri Nov 16, 2007 7:27 am    Post subject: Reply with quote

What's the point releasing only the exe? -> Of course someone would need the actual program, but I bet they would have Googled it if they needed it. If you want ppl to comment your programming habits, post the source.

btw.. W/o source I can see at least one mistake. Your program gets stuck into a loop if you input a char. So, make a check.
Back to top
View user's profile Send private message
Trow
Grandmaster Cheater
Reputation: 2

Joined: 17 Aug 2006
Posts: 957

PostPosted: Fri Nov 16, 2007 8:51 am    Post subject: Reply with quote

is it that educational to show your ability to do *9/5+32 in C++...?
_________________
Get kidnapped often.
Back to top
View user's profile Send private message
Flyte
Peanuts!!!!
Reputation: 6

Joined: 19 Apr 2006
Posts: 1887
Location: Canada

PostPosted: Fri Nov 16, 2007 9:03 am    Post subject: Reply with quote

blland wrote:
is it that educational to show your ability to do *9/5+32 in C++...?


The purpose of teaching small things such as these is not the equation in the background, but managing input and output.

Edit: Yes, you shold post the source that way we can tell you what you are doing wrong.


Last edited by Flyte on Fri Nov 16, 2007 9:04 am; edited 1 time in total
Back to top
View user's profile Send private message
Losplagos
Expert Cheater
Reputation: 0

Joined: 21 Mar 2006
Posts: 172
Location: Knee deep in a c++ book

PostPosted: Fri Nov 16, 2007 9:03 am    Post subject: Reply with quote

You should really post your source code. I will probly post mine if i feel like updating it.

EDIT here is my source.

Code:

#include <iostream>
int main()
{   
    int p;
    double t;
    double x;
    int loop = 0;
    do
    {
          std::cout << "Hello enter 1 to continue 0 to quit " << std::endl;
          std::cin >> p;
          switch(p)
          {
                    case 1:
                         std::cout << "Enter number in Fahrenheit" << std::endl;
                         std::cin >> t;
                         x=(t-32) * 5 / 9;
                         std::cout << "The answer in celsius is: " << x << std::endl;
                         break;
                    case 0:
                         std::cout << "Good bye";
                         loop = 1;
                         break;
                    default:
                            std::cout << "invalid input";
                            break;
          }
    }while(loop == 0);
}


Pretty bad but i just cooked it up with lack of sleep.

_________________

Earthbound = 31337
Back to top
View user's profile Send private message
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Fri Nov 16, 2007 12:36 pm    Post subject: Reply with quote

Losplagos wrote:
You should really post your source code. I will probly post mine if i feel like updating it.

EDIT here is my source.
- What happens if an user inputs a letter or a long number (eg. 23792374982374923749723974)?
- It gets stuck into a loop.

Btw.. You've improved your coding abilities a bit since last time :P
Back to top
View user's profile Send private message
Losplagos
Expert Cheater
Reputation: 0

Joined: 21 Mar 2006
Posts: 172
Location: Knee deep in a c++ book

PostPosted: Fri Nov 16, 2007 4:20 pm    Post subject: Reply with quote

Jani wrote:
Losplagos wrote:
You should really post your source code. I will probly post mine if i feel like updating it.

EDIT here is my source.
- What happens if an user inputs a letter or a long number (eg. 23792374982374923749723974)?
- It gets stuck into a loop.

Btw.. You've improved your coding abilities a bit since last time Razz


I was just showing him a basic example. And thanks

edit:
OK here is the better source that fixes the letter problem or long number.


Code:
#include <iostream>
int quitMessage();
int main()
{   
    int p;
    double t;
    double x;
    int loop = 0;
    do
    {
          std::cout << "Hello enter 1 to continue 0 to quit " << std::endl;
          std::cin >> p;
          while(std::cin.fail())
                         {
                          std::cout << "You did not input a number. Try again: "; // Error msg.
                        std::cin.clear(); // Clear failbit
                        std::cin.sync(); // Sync the stream
                        std::cin >> p; // Try again
                         }
          switch(p)
          {
                    case 1:
                         std::cout << "Enter number in Fahrenheit 0 to quit" << std::endl;
                         std::cin >> t;
                         while(std::cin.fail())
                         {
                          std::cout << "You did not input a number. Try again: "; // Error msg.
                        std::cin.clear(); // Clear failbit
                        std::cin.sync(); // Sync the stream
                        std::cin >> t; // Try again
                         }
                         x=(t-32) * 5 / 9;
                         std::cout << "The answer in celsius is: " << x << std::endl;
                         break;
                    case 0:
                         std::cout << "Good bye";
                         loop = 1;
                         break;
                    default:
                            std::cout << "invalid input";
                            break;
          }
    }while(loop == 0);
    return quitMessage();
}

int quitMessage()
{
    std::cout << "Bye" << std::endl;
   return EXIT_SUCCESS;
}


If you need help with my example for it please tell me jacksplitter and I will add one with comments.

edit2:
Here im doing the formula with a function and commented my code much better.

Code:
#include <iostream>
int quitMessage();
double makeula(double a);
int main()
{   
     // My variables i could use pointers here but it does'nt matter
    int p;
    double t;
    int loop = 0;
    do
    {
          std::cout << "Hello enter 1 to continue 0 to quit " << std::endl;
          std::cin >> p;
          while(std::cin.fail())
                         {
                          std::cout << "Invalid input "; // Error msg.
                        std::cin.clear(); // Clear failbit
                        std::cin.sync(); // Sync the stream
                        std::cin >> p; // Try again
                         }
          switch(p) //this is much easyer than using nested if commands
          {
                    case 1:
                         std::cout << "Enter number in Fahrenheit 0 to quit" << std::endl;
                         std::cin >> t;
                         while(std::cin.fail())
                         {
                          std::cout << "You did not input a number. Try again: "; // Error msg.
                        std::cin.clear(); // Clear failbit
                        std::cin.sync(); // Sync the stream
                        std::cin >> t; // Try again
                         }
                         // one way x=(t-32) * 5 / 9; //The formula
                         std::cout << "The answer in celsius is: " << makeula(t) << std::endl;
                         break;
                    case 0:
                         std::cout << "Good bye";
                         loop = 1; // break the do while loop
                         break;
                    default:
                            std::cout << "invalid input";
                            break;
          }
    }while(loop == 0);
    return quitMessage();
}

int quitMessage() // a simple function to do the quit message  i could probly use a function for the formula too
{
    std::cout << "Bye" << std::endl;
   return EXIT_SUCCESS; // EXIT_SUCCESS is easyer
}

double makeula(double a) // doing the formula with a function
{
       a=(a-32) * 5 / 9; //Some say you should use functions for almost everything
       return a; //returns the rusult of the formula on the line before this
}


Hope you learn something from it

_________________

Earthbound = 31337
Back to top
View user's profile Send private message
Ztaks
Newbie cheater
Reputation: 0

Joined: 18 Nov 2007
Posts: 16

PostPosted: Sun Nov 18, 2007 3:57 pm    Post subject: Reply with quote

that can be much more efficient O_O
_________________
I'm in your server scanning for vulnerabilities ^^
Back to top
View user's profile Send private message
TheSorc3r3r
I post too much
Reputation: 0

Joined: 06 Sep 2006
Posts: 2404

PostPosted: Sun Nov 18, 2007 6:59 pm    Post subject: Reply with quote

lol losplagos, why don't you just put 'using namespace std' at the top and save yourself a lot of typing?

lol calvin, get it through your head that C++ is not efficient ;_;

_________________


Don't laugh, I'm still learning photoshop!
Back to top
View user's profile Send private message
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Mon Nov 19, 2007 4:09 am    Post subject: Reply with quote

TheSorc3r3r wrote:
lol losplagos, why don't you just put 'using namespace std' at the top and save yourself a lot of typing?
Because not everyone wants to destroy that feature of C++. C is freaking annoying when there's no namespaces -> You just can't name your functions whatever you want. Actually I'd recommend ppl NOT to put that "using namespace std" at the top, so they wouldn't mix their own and std functions. You should code something a bit "bigger" and you'd notice that namespaces are so <3.

PS. Besides, typing 5 extra letter won't take so long.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites