I have to make a program with program control and specific task functions. I'm supposed to call 2 specific task functions to my program. I wrote the code for them in the process_area, but I can't compile the program at all. I'm not sure what's wrong with the code.
In your code you defined the functions inside of another function instead of calling them. Define the functions outside of the process data function and call them inside of the process data function.
That whole calling part is confusing me. What should I use instead in that area (sorry if it comes off as sounding off). I'm extremely confused.
Here's the pseudocode:
Function main
Pass In: nothing
Call: get_data
Call: process_data
Call: show_results
Pass Out: zero to the OS
Endfunction
********************
Function get_data
Pass In: nothing
display a message asking user for the length of the property in feet
get the length of the rectangle in feet from the keyboard
display a message asking user for the width of the property in feet
get the width of the rectangle in feet from the keyboard
Pass Out: nothing
Endfunction
********************
Function process_data
Pass In: nothing
Calculate the total area of the property in acres by:
1.Calling the area_rectange function passing in length and width
2.then dividing by the number of square feet in an acre
Calculate the farmable area in acres by:
1.Calling the area_circle function passing the radius
2.then dividing by number of square feet in an acre
Calculate the non-farmable area in acres by:
1.subtracting farmable area from the property area
Pass Out: nothing
Endfunction
********************
Function show_results
Pass In: nothing
display the total area of the property in acres with an appropiate message
display the farmable area in acres with an appropiate message
display the non-farmable area in acres with an appropiate message
Call: pause_m
Pass Out: nothing
Endfunction
No, on lines 68 and 75 you make function declarations instead of function calls, and then try to divide them by 43560, which makes no sense. You need to call the functions, not declare or define them. Reread the tutorial.
- You need to declare the variable total_area_of_property and the others
- You need to pass arguments to the function call, right now you are just copy-pasting the declaration.
// Headers and Other Technical Items
#include <iostream>
usingnamespace std;
#include "C:\\Dev-Cpp\\user_library\\udst_monitor.h"
#include "C:\\Dev-Cpp\\user_library\\udst_geo_area.h"
// Function Prototypes
void get_data(void);
void process_data(void);
void show_results(void);
// Variables
double rectangle_length;
double rectangle_width;
double total_area_of_property;
double farmable_area_in_acres;
double non_farmable_area_in_acres;
int square_ft_acre;
//******************************************************
// main
//******************************************************
int main(void)
{
get_data();
process_data();
show_results();
return 0;
}
//******************************************************
// get data
//******************************************************
void get_data(void)
{
cout << "\nEnter the length of the property in feet --->: ";
cin >> rectangle_length;
cout << "\nEnter the width of the property in feet ---->: ";
cin >> rectangle_width;
return;
}
//******************************************************
// process data
//******************************************************
void process_data(void)
{
//******************************************************
// area_rectangle
//******************************************************
double //should I keep the double part here? or not? because I don't get an error message if I take it out
total_area_of_property = area_rectangle (rectangle_length, rectangle_width) / 43560 ;
//******************************************************
// area_circle
//******************************************************
//Now if I keep the double in the area_rectangle or not, I get an error message in this line
double farmable_area_in_acres = area_circle (radius) / 43560 ;
//******************************************************
// non_farmable area
//******************************************************
non_farmable_area_in_acres = total_area_of_property - farmable_area_in_acres;
return;
}
//******************************************************
// show results
//******************************************************
void show_results(void)
{
cout << "\n";
cout << "\nThe total area of the property in acres is ---->: ";
cout << total_area_of_property;
cout << "\nThe total farmable area in acres is -----> ";
cout << farmable_area_in_acres;
cout << "\nThe total non-farmable area in acres is -----> ";
cout << non_farmable_area_in_acres;
pause_m();
return;
}
//******************************************************
// End of Program
//******************************************************
You get that error because you didn't define radius anywhere.
And whether or not you put double there for them depends on if you want to assign to the global variables or not. Don't put double if you want to assign to the global variables.