0

The goal of these functions in the end is to show someone's total fee's for being consulted, which is based off whether or not they have a low income. The functions are supposed flow downwards to get each needed value in order to calculate the total. I do not understand how to fix the various errors in my code, such as some variables not being declared in a specific scope, even though I thought i declared them correctly.

#include <iostream>
using namespace std;

const double HighIncomeRate = .7;
const double LowIncomeRate = .4;

bool isLowIncome();

int main() {
  double Fee;
  double ConsultTime;

  cout << "Your fee is: " << getcalcFee(consultTime, Income) << endl;
  return 0;
}
bool isLowIncome() {
  double Income;

  cout << "What is your income: " << endl;
  cin >> Income;
  cout << "How long have you been consulted" << endl;
  cin >> ConsultTime;

  if (Income <= 25000) {
    return true;
  } else {
    return false;
  }
}
double calcFee(int &ConsultTime, const double HighIncomeRate,
               const double LowIncomeRate) {

  if (isLowIncome == true) {
    if (ConsultTime <= 30) {
      calcFee = 0
    } else {
      calcFee = LowIncomeRate * 50((ConsultTime - 30) / 60)
    }
  }
  if {
    if (ConsultTime <= 20) {
      calcFee = 0
    } else {
      calcFee = HighLowRate * 50((ConsultTime - 20) / 60)
    }
  }
  return 0;
}
Paul Rooney
  • 20,879
  • 9
  • 40
  • 61
o9ka
  • 19
  • 3
  • 2
    There are many things wrong. Get a good beginner's book. – DeiDei Oct 13 '17 at 03:51
  • Bear in mind variables declared inside other functions are not available for use. They are out of scope. Also that case is important `ConsultTime` != `consultTime`. Also `if (isLowIncome == true) {` you didnt call the function here. – Paul Rooney Oct 13 '17 at 03:52
  • you call `getcalcFee(...)` in main but the function is actually called `calcFee(...)` call it with `calcFee(...)` https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list – Manvir Oct 13 '17 at 04:04

0 Answers0