So I'm getting some errors I can't account for in this code I'm writing. It's only very simple code, and I haven't been learning C++ for very long so I know some of my variable names may not be particularly descriptive and stuff like that, but that's not what I need help with, so please, just help with the errors.
#include <iostream>
int trig()
{
float x;
float y;
char op;
cout << "Choose a trigonometry operation ('s' for sin, 'c' for cos or 't' for tan): " << endl;
cin >> op >> endl;
if (op == 's')
cin << "Enter the opposite side: " << endl;
cin >> x >> endl;
cout << "Enter the hypotenuse: " << endl;
cin >> y >> endl;
cout << "sin of " << x << "/" << y << " = " << x/y << endl;
if (op == 'c')
cin << "Enter the adjacent side: " << endl;
cin >> x >> endl;
cout << "Enter the hypotenuse: " << endl;
cin >> y >> endl;
cout << "cos of " << x << "/" << y << " = " << x/y <<endl;
if (op == 't')
cout << "Enter the opposite side: " << endl;
cin >> x >> endl;
cout << "Enter the adjacent side: " << endl;
cin >> y >> "\n"
cout << "cos of " << x << "/" << y << " = " << x/y << endl;
}
int standard()
{
float x;
char op;
float y;
cin << "You have selected standard mode" << endl;
cin << "Please enter a number up to 2 decimal points: " << endl;
cin >> x >> endl;
cin << "Please enter an operator (choose from +,-,* or /): " << endl;
cin >> op >> endl;
cin << "Please enter a second number up to 2 decimal places: " << endl;
cin >> y >> endl;
if (op == '+')
cin << x << " + " << y << " = " << x+y << endl;
if (op == '-')
cin << x << " - " << y << " = " << x-y << endl;
if (op == '*')
cin << x << " * " << y << " = " << x*y << endl;
if (op == '/')
cin << x << " / " << y << " = " << x/y << endl;
}
int main()
{
char mode;
cin << "Choose a mode - standard or trigonometry operations ('s' for standard or 't' for trigonometry): " << endl;
cin >> mode >> endl;
if (mode == 's')
standard()
if (mode == 't')
trig()
}
/Users/Keelan/Desktop/Advanced Calculator/main.cpp:9:0 /Users/Keelan/Desktop/Advanced Calculator/main.cpp:9: error: 'cout' was not declared in this scope
/Users/Keelan/Desktop/Advanced Calculator/main.cpp:9:0 /Users/Keelan/Desktop/Advanced Calculator/main.cpp:9: error: 'endl' was not declared in this scope
/Users/Keelan/Desktop/Advanced Calculator/main.cpp:10:0 /Users/Keelan/Desktop/Advanced Calculator/main.cpp:10: error: 'cin' was not declared in this scope
/Users/Keelan/Desktop/Advanced Calculator/main.cpp:40:0 /Users/Keelan/Desktop/Advanced Calculator/main.cpp:40: error: 'cin' was not declared in this scope
/Users/Keelan/Desktop/Advanced Calculator/main.cpp:40:0 /Users/Keelan/Desktop/Advanced Calculator/main.cpp:40: error: 'endl' was not declared in this scope
/Users/Keelan/Desktop/Advanced Calculator/main.cpp:65:0 /Users/Keelan/Desktop/Advanced Calculator/main.cpp:65: error: no match for 'operator<<' in 'std::cin << "Choose a mode - standard or trigonometry operations (\'s\' for standard or \'t\' for trigonometry): "'
/Users/Keelan/Desktop/Advanced Calculator/main.cpp:66:0 /Users/Keelan/Desktop/Advanced Calculator/main.cpp:66: error: no match for 'operator>>' in 'std::operator>> [with _CharT2 = char, _Traits2 = std::char_traits<char>, _CharT = char, _Traits = std::char_traits<char>](((std::basic_istream<char, std::char_traits<char> >&)(& std::cin)), ((char&)(& mode))) >> std::endl'
I HAD that line in, but removed it as it was giving me even more errors. Not sure if I put it right at the top though, will try. Thanks
EDIT: tried that, gives me more errors again:
Category: Error: Other
/Users/Keelan/Desktop/Advanced Calculator/main.cpp:12:0 No match for 'operator>>' in 'std::operator>> [with _CharT2 = char, _Traits2 = std::char_traits<char>, _CharT = char, _Traits = std::char_traits<char>](((std::basic_istream<char, std::char_traits<char> >&)(& std::cin)), ((char&)(& op))) >> std::endl'
/Users/Keelan/Desktop/Advanced Calculator/main.cpp:15:0 No match for 'operator<<' in 'std::cin << "Enter the opposite side: "'
/Users/Keelan/Desktop/Advanced Calculator/main.cpp:16:0 No match for 'operator>>' in 'std::cin. std::basic_istream<_CharT, _Traits>::operator>> [with _CharT = char, _Traits = std::char_traits<char>](((float&)(& x))) >> std::endl'
/Users/Keelan/Desktop/Advanced Calculator/main.cpp:18:0 No match for 'operator>>' in 'std::cin. std::basic_istream<_CharT, _Traits>::operator>> [with _CharT = char, _Traits = std::char_traits<char>](((float&)(& y))) >> std::endl'
/Users/Keelan/Desktop/Advanced Calculator/main.cpp:22:0 No match for 'operator<<' in 'std::cin << "Enter the adjacent side: "'
/Users/Keelan/Desktop/Advanced Calculator/main.cpp:23:0 No match for 'operator>>' in 'std::cin. std::basic_istream<_CharT, _Traits>::operator>> [with _CharT = char, _Traits = std::char_traits<char>](((float&)(& x))) >> std::endl'
/Users/Keelan/Desktop/Advanced Calculator/main.cpp:25:0 No match for 'operator>>' in 'std::cin. std::basic_istream<_CharT, _Traits>::operator>> [with _CharT = char, _Traits = std::char_traits<char>](((float&)(& y))) >> std::endl'
/Users/Keelan/Desktop/Advanced Calculator/main.cpp:30:0 No match for 'operator>>' in 'std::cin. std::basic_istream<_CharT, _Traits>::operator>> [with _CharT = char, _Traits = std::char_traits<char>](((float&)(& x))) >> std::endl'
/Users/Keelan/Desktop/Advanced Calculator/main.cpp:32:0 No match for 'operator>>' in 'std::cin. std::basic_istream<_CharT, _Traits>::operator>> [with _CharT = char, _Traits = std::char_traits<char>](((float&)(& y))) >> std::endl'
/Users/Keelan/Desktop/Advanced Calculator/main.cpp:42:0 No match for 'operator<<' in 'std::cin << "You have selected standard mode"'
/Users/Keelan/Desktop/Advanced Calculator/main.cpp:43:0 No match for 'operator<<' in 'std::cin << "Please enter a number up to 2 decimal points: "'
/Users/Keelan/Desktop/Advanced Calculator/main.cpp:44:0 No match for 'operator>>' in 'std::cin. std::basic_istream<_CharT, _Traits>::operator>> [with _CharT = char, _Traits = std::char_traits<char>](((float&)(& x))) >> std::endl'
/Users/Keelan/Desktop/Advanced Calculator/main.cpp:45:0 No match for 'operator<<' in 'std::cin << "Please enter an operator (choose from +,-,* or /): "'
/Users/Keelan/Desktop/Advanced Calculator/main.cpp:46:0 No match for 'operator>>' in 'std::operator>> [with _CharT2 = char, _Traits2 = std::char_traits<char>, _CharT = char, _Traits = std::char_traits<char>](((std::basic_istream<char, std::char_traits<char> >&)(& std::cin)), ((char&)(& op))) >> std::endl'
/Users/Keelan/Desktop/Advanced Calculator/main.cpp:47:0 No match for 'operator<<' in 'std::cin << "Please enter a second number up to 2 decimal places: "'
/Users/Keelan/Desktop/Advanced Calculator/main.cpp:48:0 No match for 'operator>>' in 'std::cin. std::basic_istream<_CharT, _Traits>::operator>> [with _CharT = char, _Traits = std::char_traits<char>](((float&)(& y))) >> std::endl'
/Users/Keelan/Desktop/Advanced Calculator/main.cpp:51:0 No match for 'operator<<' in 'std::cin << x'
/Users/Keelan/Desktop/Advanced Calculator/main.cpp:54:0 No match for 'operator<<' in 'std::cin << x'
/Users/Keelan/Desktop/Advanced Calculator/main.cpp:57:0 No match for 'operator<<' in 'std::cin << x'
/Users/Keelan/Desktop/Advanced Calculator/main.cpp:60:0 No match for 'operator<<' in 'std::cin << x'
/Users/Keelan/Desktop/Advanced Calculator/main.cpp:67:0 No match for 'operator<<' in 'std::cin << "Choose a mode - standard or trigonometry operations (\'s\' for standard or \'t\' for trigonometry): "'
/Users/Keelan/Desktop/Advanced Calculator/main.cpp:68:0 No match for 'operator>>' in 'std::operator>> [with _CharT2 = char, _Traits2 = std::char_traits<char>, _CharT = char, _Traits = std::char_traits<char>](((std::basic_istream<char, std::char_traits<char> >&)(& std::cin)), ((char&)(& mode))) >> std::endl'
int standard()
{
float x;
char op;
float y;
cin << "You have selected standard mode" << endl;
cin << "Please enter a number up to 2 decimal points: " << endl;
cin >> x >> endl;
cin << "Please enter an operator (choose from +,-,* or /): " << endl;
cin >> op >> endl;
cin << "Please enter a second number up to 2 decimal places: " << endl;
cin >> y >> endl;
if (op == '+')
cin << x << " + " << y << " = " << x+y << endl;
if (op == '-')
cin << x << " - " << y << " = " << x-y << endl;
if (op == '*')
cin << x << " * " << y << " = " << x*y << endl;
if (op == '/')
cin << x << " / " << y << " = " << x/y << endl;
}