Ok im working on learning c++ and im working on a calculator atm but i cant get it to say "I'm your calculator, how may i help you?" and i want it go to the next sentince when you hit enter wich would be
Code:
cout << " please enter the first number you'd like to calculate " << endl ; // the first number you type in
:
then you type it in the number hit enter then +, -, or /. hit enter then it will ask for the 2ed number and you type that in and hit enter and it will add it and display the answer.
Code:
// pew pew calculator.cpp : main project file.
#include "stdafx.h"
#include <iostream>
using namespace std ;
int main ()
{
char response ;
int firstnumber ;
int secondnumber ;
cout << " please enter the first number you'd like to calculate " << endl ; // the first number you type in
cin>> firstnumber ; // hit enter
cout << " please enter which operation you wanna do "<< endl ; // +, -, dev etc.
cin >> response ; // hit enter agin
cout << " please enter the second number you'd like to calculate " << endl ; // the second number you type in
cin >> secondnumber ;
if (response == '+'){
cout << firstnumber << " + " << secondnumber << " = " << firstnumber+secondnumber << endl ;
};
if (response == '-'){
cout << firstnumber << " - " << secondnumber << " = " << firstnumber-secondnumber << endl ;
};
if (response == '*'){
cout << firstnumber << " * " << secondnumber << " = " << firstnumber*secondnumber << endl ;
};
if (response == '/'){
cout << firstnumber << " / " << secondnumber << " = " << firstnumber/secondnumber << endl ;
cout << " and the remainder fot the devision would be " << firstnumber%secondnumber<< endl ;
};
char f ;
cin >> f ;
return 0 ;
}
Im just asking for help so please don't at me callin me a noob and all please.
Posts 1–15 of 20 · Page 1 of 2
Post a Reply
Tags for this Thread
None
go post it in C++ section
/request move
either way whats the problem?
You never said what you need help with
Sorry I forgot there was a c++ sec i pretty much stay on CA sec, mod can you please move?
i need help geting it to say "I'm your calculator, how may i help you?" and hit enter to go to the next line. if that made sence
I don't think you can do that...search google? because that is somethign simple that you can probably get off google
cout << "I'm your calculator, how may i help you?" ; you are creating an Console app arent you ?
Originally Posted by whit
cout << "I'm your calculator, how may i help you?" ; you are creating an Console app arent you ?
what else would it be?
Originally Posted by PashaAmd
what else would it be?
He could be creating a dll or something
Ok Ill look it up, yes atleast I'm trying to.
every time i do that it wont work when i go to debug it.
Edit: Ok i got it to say what i want its just the hitting enter part thats not working but Ill see what I can find on google.
dude i don't even think it is neccessary to debug it if you can't have it go to the next line..
just google it..
char * nothingreally;
cout >> " I am bla bla bla"
cin << nothing really// no matter what they put they it is a string.. :P
works for me
what im trying to do is make it were you have to hit enter after "cout << "I'm your calculater, how may I help you?" << endl;" appears to make it go to "cout << " please enter the first number you'd like to calculate " << endl ;" if that made anysence.
this
cout << "I'm your calculater, how may I help you?" << endl;"