Hello all! C++ noob here!
I took part 1 of C++ back in 2006, and I'm suffering from CRS(Can't remember shit). I passed the class with C, average, I guess a good grade for C++.
Never took part 2.
Now, after 7 years, I want to get my feet wet again.
Started doing basic stuff, have a book (Adams & Nyhoff C++: An Introduction to Computing [3rd Edition]), and a couple of PDFs, including C++ for dummies.
So I was able to do a couple of area, radius, etc..for triangle and circles and squares...I did the Fahr to Cels, and a separate code for C to F.
I guess I was thinking "I'm a big boy now", and wanted to jump in the deep end of the pool, adding Kelvin, and doing it in a if-else statement.
The thing is:
That in my logic, I guess I'm doing it correctly, HOWEVER, the compiler, Dev C++ V. 5.4.2, for Windows, is giving me an error, a simple error, of a semi-colon.
(Line 51 column 6 C:\Users\Administrator\Desktop\ProgramasCPP\CPP Programs\Celsius-Kelvin-Fahrenheit.cpp [Error] stray '\327' in program
C:\Users\Administrator\Desktop\ProgramasCPP\CPP Programs\Celsius-Kelvin-Fahrenheit.cpp In function 'int main()':Line 51 column 20 C:\Users\Administrator\Desktop\ProgramasCPP\CPP Programs\Celsius-Kelvin-Fahrenheit.cpp [Error] expected ';' before numeric constant)
and FOR THE LIFE OF ME, I cannot understand WHY, since it has a semicolon.
I will post the code, for you to see.
Don't worry about the cout(s), they are in Spanish, but the code is in English.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
/*Programa para calcular temperaturas entre Celsius, Fahrenheit y Kelvin, utilizando if else. */
#include <iostream>
using namespace std;
int main()
{
float TempC, TempF, TempK;
cout << "Programa para convertir distintas escalas de temperaturas\n";
cout << "Por favor indique cual temperatura desea convertir,\n";
cout << "y el sistema hara 2 conversiones.";
cout << "\nElija 1, para Celsius:\n";
cout << "Elija 2, para Fahrenheit:\n";
cout << "Elija 3, para Kelvin: \n";
char select;
cin >> select;
if (select==1)
{
cout << "Usted ha seleccionado convertir una temperatura Celsius.\n";
cout << "Entre la temperatura Celsius, y el sistema devolvera Fahrenheit y Kelvin.\n";
cin >> TempC;
TempK = TempC + 273.15;
TempF = (1.8 * TempC) +32;
cout << "La conversion de " << TempC << "° a grados Fahrenheit es: " << TempF << "grados.\n";
cout << "La conversion de " << TempC << "° a grados Kelvin: " << TempK << "grados.\n";
}
else if (select==2)
{
cout << "Usted ha seleccionado convertir una temperatura Fahrenheit.\n";
cout << "Entre la temperatura Fahrenheit, y el sistema devolvera Celsius y Kelvin.\n";
cin >> TempF;
TempC = (TempF-32) /1.8;
TempK = (TempF+459.67) /1.8;
cout << "La conversion de " << TempF << "° a grados Celsius es: " << TempC << "grados.\n";
cout << "La conversion de " << TempF << "° a grados Kelvin: " << TempK << "grados.\n";
}
else
{
cout << "Usted ha seleccionado convertir una temperatura Kelvin.\n";
cout << "Entre la temperatura Kelvin, y el sistema devolvera Celsius y Kelvin.\n";
cin >> TempK;
TempF = TempK×1.8-459.67; //The error code is here, in line 51
TempC = TempK-273.15;
cout << "La conversion de " << TempK << "° a grados Fahrenheit es: " << TempF << "grados.\n";
cout << "La conversion de " << TempK << "° a grados Celsius: " << TempC << "grados.\n";
}
return 0;
}
|
Thank you all!