so i just started programming and am tottaly loveing it
(my first problem was to make a program to conver fahrenheit to kelvin and celcius
if you wan to know here is what i got but thats just if you are curious in how i did it
(yes i did this by myself using all of my noob c++ knowledge)
Code:
#include <iostream>
using namespace std;
int main()
{
float Celcius,Fahrenheit,Kelvin;
cout << "Enter Fahrenheit degrees to get Kelvin and Celcius";
cin >> Fahrenheit;
cin.get();
Celcius=(Fahrenheit-32)/1.8;
if (Celcius <-273.15) cout << "This temperature is impossible" << endl;
else
cout << "Celcius is" << Celcius;
cout << "" << endl ;// This makes the program eaiser to read
Kelvin=(Celcius+273.15);
if (Kelvin<0) cout << "This is below absolute zero" << endl;
else
cout << "Kelvin is" << Kelvin << endl;
cin.get();
return 0;
}
but (that was my homework and im done with it) but now i want to write another program
(just for fun)
so here is what i want to do
write a program that ask the user if he/she loves the computer
ex
cout << "Hello whats your name?";
either (cin >> name; ) or (getline (cin, name; )
but i can't us e
if or else if or any of those
becouse i want to cout different answers for different cin's
any ideas??
(just for fun nothing else)
heres what I tried and failed in miserably so far
Code:
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string name,answer; // is this right??
cout << "Hello, What's your name? ";
cin >> name;
cout << "Hello " << name << "do you love me?\n";
cin >> answer;
if (answer=yes) // and obciously this didnt work
cout << "I love you too... Marry ME!\n";
/*else if (blabla
cout << bla bla
else if (blab lblablab*/
// you can see my reasoning but well this is not ints or floats
// so i have no idea how to approach this
return 0;
}
please note im not going for AI just a simple little in and out transaction
something that my friends and i can mess around with( ahhh im falling in love with programing)
I had my doubts about if/else working but a man can hope