//compares the amount the user has in deposits to the price of app selected.
//It returns 1 if the amount is enough to cover the cost, 0 if there is not enough.
int Compare(double deposit, double choiceCost);
how do you get this function to compare return 1 or 0?
i have double balance = 0.0; declared already and previously used *depositPtr as well as *choiceCostPtr.
????????????????
if(balance>=choiceCost)
{
return 1;
}
else
{
return 0;
}
Or at least can someone tell me steps on how I could make this work.
To make the Compare() function return 1 or 0 based on whether the deposit amount is enough to cover the cost of the chosen app, you can follow these steps:
1. Declare the Compare() function with the appropriate return type and parameters:
```c++
int Compare(double deposit, double choiceCost);
```
2. Implement the function as follows:
```c++
int Compare(double deposit, double choiceCost) {
if (deposit >= choiceCost) {
return 1;
} else {
return 0;
}
}
```
3. Before calling the Compare() function, make sure you have the deposit amount stored in a double variable, such as `deposit`, and the cost of the selected app stored in another double variable, such as `choiceCost`.
4. Call the Compare() function with the appropriate arguments and store the result in an int variable, such as `result`:
```c++
int result = Compare(deposit, choiceCost);
```
Now, the `result` variable will contain either 1 or 0 based on whether the deposit amount is enough to cover the cost of the selected app.