So I wrote this code so that, given some user inputs, would output how long it would take to mow a lawn. I originally had 'timetaken' as a function, but it was outputting a number that looked hexadecimal in format in the dubugging stage.
I have since changed timetaken to a simple equation, and put 'housearea' and 'gardenarea' as functions (since I have to include at least one for this assignment). The problem is, now both housearea and gardenarea are outputting hexadecimal-esque numbers, but timetaken is fine. Am I doing something weird with my functions which is causing this to happen? Thanks in advance.
#include <iostream>
usingnamespace std;
int gardenarea(int length, int width)
{
int ga;
ga = length * width;
return ga;
}
int housearea(int side)
{
int ha;
ha = side * side;
return ha;
}
int main()
{
int length, width, side, mowingrate, timetaken;
cout << "Please enter length of garden in metres. " << endl;
cin >> length;
cout << "Please enter width of garden in metres. " << endl;
cin >> width;
gardenarea(length, width);
cout << "Area of garden is " << gardenarea << " m^2." << endl;
cout << "Please enter length of side of house in metres. " << endl;
cin >> side;
housearea(side);
cout << "Area of house is " << housearea << "m^2." << endl;
cout << "Please enter mowing rate, assuming the mowing rate unit is square metres per minute. " << endl;
cin >> mowingrate;
timetaken = gardenarea(length,width) - housearea(side) / mowingrate;
cout << "Time taken to mow garden is " << timetaken << " minutes." << endl;
return 0;
}