C++ console application

Posts 115 of 40 · Page 1 of 3
C++ console application
Code:
#include "stdafx.h"

#include <iostream>

using namespace std;

int main()
{
  int number;

  cout<<"Please enter a number: ";
  cin>> thisisanumber;
  cin.ignore();
  cout<<"You entered: "<< number <<"\nPress any key to continue...";
  cin.get();
}
This is what I have so far, and it builds just fine... runs fine as well... What I want though, is to get something similar to this.

Code:
#include "stdafx.h"

#include <iostream>

using namespace std;

int main()
{
  int number;

  cout<<"Please enter a number: ";
  cin>> thisisanumber;
  cin.ignore();
  cout<<"You entered: "<< number <<"\nyes or no?";
  cin.get();
}
What I can't figure out how to do is get it to actually read the answer and display something else. This would use the If statement, but I'm not completely sure as to how to use that statement.


Basically, how I want this application to run is like this
Code:
Please enter a number
>23
You entered 23, yes or no?
>yes

if yes then
yeah, thats right, I got it...
else
wtf? I got it wrong? But my psychic powers never fail me...
>anything at all
Do you like wafflezzz?????
>no
if no then 
WTF??? YOU DON'T LIKE WAFFLES?
else 
do you like syrup on your waffles?
if yes then
And please explain each and every statement you are using that has to do with if... I don't want to know how to use it, I want to understand it.
[php]#include <iostream>
using namespace std;

int main()
{
int thisIsANumber;
char yesOrNo;
char likeShitTacos;
cout << "Enter number\n";
cin >> thisIsANumber;
cout << "You entered " << thisIsANumber << " (Y/N)?\n";
cin >> yesOrNo;
if(yesOrNo == 'y')
{
cout << "This is for yes\n";
}
else if(yesOrNo == 'n')
{
cout << "This is for no\n";
}
else
{
cout << "Do you like shit tacos??\n";
cin >> likeShitTacos;
if(likeShitTacos == 'y')
{
cout << "You dirty asshole\n";
}
else if(likeShitTacos == 'n')
{
cout << "If you did fuck you\n";
}
else
{
cout << "Not a choice fucktard\n";
}
}

cin.get();
return 0;
} [/php]
Quote Originally Posted by VvITylerIvV View Post

And please explain each and every statement you are using that has to do with if... I don't want to know how to use it, I want to understand it.
Quote Originally Posted by Kallisti View Post
[php]#include <iostream>
using namespace std;

int main()
{
int thisIsANumber;
char yesOrNo;
char likeShitTacos;
cout << "Enter number\n";
cin >> thisIsANumber;
cout << "You entered " << thisIsANumber << " (Y/N)?\n";
cin >> yesOrNo;
if(yesOrNo == 'y')
{
cout << "This is for yes\n";
}
else if(yesOrNo == 'n')
{
cout << "This is for no\n";
}
else
{
cout << "Do you like shit tacos??\n";
cin >> likeShitTacos;
if(likeShitTacos == 'y')
{
cout << "You dirty asshole\n";
}
else if(likeShitTacos == 'n')
{
cout << "If you did fuck you\n";
}
else
{
cout << "Not a choice fucktard\n";
}
}

cin.get();
return 0;
} [/php]
gtfo
Quote Originally Posted by Toxic Waltz View Post
Thanks.
Why put anything after you've returned from the main function?

[php]
return 0;
cin.get();
[/php]

/
Quote Originally Posted by Void View Post
Why put anything after you've returned from the main function?

[php]
return 0;
cin.get();
[/php]

/
Oops. Fixed. Still compiles and works though /
Why so mad bro. I took the 2 minutes to make that for you
I do not think you are in the position to tell someone to gtfo, especially after they've just helped you. Accept the help you get or just never post in this section..
Agreed with Void and TailsTehFox
I think if the guy read his script enough and applied it to his work he would of figured it out.
Its a simple coding program but if you want to save boat loads of time do this on a Microsoft program called small basic. I have made many programs like that in it. It takes less than 10 mins.
Quote Originally Posted by dddrrr View Post
Its a simple coding program but if you want to save boat loads of time do this on a Microsoft program called small basic. I have made many programs like that in it. It takes less than 10 mins.
lolwut...? and he wont learn.. kk
Quote Originally Posted by Kallisti View Post
Why so mad bro. I took the 2 minutes to make that for you
Because, I don't understand any If statements, I don't understand what the hell char is and what the hell int is. I asked for an explanation to what it is. Ok, now sure I can use it but I don't know what the **** it is.
Quote Originally Posted by Void View Post
I do not think you are in the position to tell someone to gtfo, especially after they've just helped you. Accept the help you get or just never post in this section..
I did accept the help, that one choob helped me. And I thanked him for it.

Quote Originally Posted by faceofdevil View Post
I think if the guy read his script enough and applied it to his work he would of figured it out.
I think if I read it I would've been confused. I don't understand if statements, char and ints, I want to learn not be able to use.

Quote Originally Posted by dddrrr View Post
Its a simple coding program but if you want to save boat loads of time do this on a Microsoft program called small basic. I have made many programs like that in it. It takes less than 10 mins.
I use a $16,000 program called visual studio ultimate. (I hope I don't get sued...)
I think if I read it I would've been confused. I don't understand if statements, char and ints, I want to learn not be able to use.

Code:
Please enter a number
>23
You entered 23, yes or no?
>yes

IF yes then
yeah, thats right, I got it...
else
wtf? I got it wrong? But my psychic powers never fail me...
>anything at all
Do you like wafflezzz?????
>no
if no then 
WTF??? YOU DON'T LIKE WAFFLES?
else 
do you like syrup on your waffles?
if yes then
If you applyed your english skills to that of your math skills you would of understand what you where trying to build. In any project you do this will always come up.

btw good job so far
Posts 115 of 40 · Page 1 of 3
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?