This is my first time trying to integrate a header into my C++ homework. We haven't covered it in class yet, I'm just being ambitious. I'm working with Clion.
If it isn't obvious, my goal is to spell out two functions in the header, 1 to convert from Celsius to Fahrenheit, the other is the opposite.
Errors:
/home/dylan/ClionProjects/tempconversion/main.cpp:18:1: error: expected unqualified-id before ‘if’
if (choice = 1);
^
/home/dylan/ClionProjects/tempconversion/main.cpp:19:1: error: expected unqualified-id before ‘{’ token
{
^
/home/dylan/ClionProjects/tempconversion/main.cpp:23:1: error: expected unqualified-id before ‘else’
else if (choice = 2)
^
/home/dylan/ClionProjects/tempconversion/main.cpp:27:1: error: expected unqualified-id before ‘else’
else if (choice = 0)
^
/home/dylan/ClionProjects/tempconversion/main.cpp:31:1: error: expected unqualified-id before ‘else’
else
^
functions.h header:
//
// Created by dylan on 7/3/16.
//
#ifndef TEMPCONVERSION_FUNCTIONS_H
#define TEMPCONVERSION_FUNCTIONS_H
#include <iostream>
int choice;
int degrees;
double degrees2;
double f2c()
{
std::cout << "Enter the degree count in whole numbers n";
std::cin >> degrees;
degrees2 = (degrees-32)/1.8;
std::cout << degrees2;
}
double c2f()
{
std::cout << "Enter the degree count in whole numbers n";
std::cin >> degrees;
degrees2 = (degrees * 1.8) + 32;
std::cout << degrees2;
}
#endif //TEMPCONVERSION_FUNCTIONS_H
main.cpp
include <iostream>
#include </home/dylan/ClionProjects/tempconversion/functions.h>
using namespace std;
int conMenu()
{
std::cout << "Would you like to: n";
std::cout << "1. Convert Celsius to Fahrenheit n";
std:: cout << "2. convert Fahrenheit to Celsius n";
std::cout << "0. Exit the program";
std:: cout << "Please enter your choice: ";
std::cin >> choice;
}
if (choice = 1);
{
double c2f();
}
else if (choice = 2)
{
double f2c();
}
else if (choice = 0)
{
retu 0;
}
else
{
retu 0;
}
