Not declared in this scope

Hi im working on a program for school and I feel like I had everything organized right and everything coded right but when i compile it tells me almost all the variables are not declared in this scope. I really did not want to ask for help, I've been trying to figure this out for about a week but i still haven't been able too. Any help would be much appreciated. Im sorry if the answer is really simple ive just started learning functions

code provided below
https://gist.github.com/anonymous/41f4e6ef60c17522d439f31e45ae65fd
On line 38-39
1
2
    carpetArea = setdata(name, idNum, lengthFeet, lengthInches, widthFeet, widthInches, carpetPricePer, discountPercent, widthFeetCalc, lengthFeetCalc);
    calculations(installPrice, finalPrice, subtotal);

you are calling the function setdata, but the variables are not declared.
Also, the same thing is happening to your calculations function.

On line 98-105...
1
2
3
4
5
6
7
8
void calculations(float & installPrice, float & finalPrice, float & subtotal)
{

    installPrice = calcinstalled(carpetCost, laborCost, carpetArea, carpetPricePer, LABOR);
    subtotal = calcsubtotal(discountDecimal, discountAmount, discountPercent, installPrice);
    finalPrice = calctotal(taxesAmount, TAX, subtotal);

}


You are not declaring the variables carpetCost, laborCost, carpetArea, carpetPricePer,discountDecimal, discountAmount, discountPercent, taxesAmount

On line 130-136...
1
2
3
4
5
6
7
void showresult()
{

    headings(name, idNum);
    measurments(lengthFeet, lengthInches, widthFeet, widthInches, carpetArea);
    charges(carpetPricePer, carpetCost, LABOR, laborCost, installPrice, discountPercent, discountAmount, subtotal, taxesAmount, finalPrice);
}


You are not declaring the variables name, idNum, lengthFeet, lengthInches, widthFeet, widthInches, carpetArea, carpetPricePer, carpetCost, laborCost, installPrice, discountPercent, discountAmount, subtotal, taxesAmount, finalPrice

Maybe, if you take a look at this link, it may help you a little more about how functions work.
http://www.cplusplus.com/doc/tutorial/functions/
In Main you are trying to pass variables to the functions but as the error says they are not declared. The same is the case in your calculations function and showresult function. The varaible you use need to either be passed to the function or declared in the function.
An example.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// This program demonstrates that changes to a function parameter
// have no affect on the original argument.
#include <iostream>
using namespace std;

// Function Prototype
void changeMe(int);

int main()
{
   int number = 12;

   // Display the value in number.
   cout << "number is " << number << endl;
   
   // Call changeMe, passing the value in number
   // as an argument.
   changeMe(number);
   
   // Display the value in number again.  
   cout << "Now back in main again, the value of ";
   cout << "number is " << number << endl;
   return 0;
}

//**************************************************************
// Definition of function changeMe.                            *
// This function changes the value of the parameter myValue.   *
//**************************************************************

void changeMe(int myValue)
{
   // Change the value of myValue to 0.
   myValue = 0;
   
   // Display the value in myValue.
   cout << "Now the value is " << myValue << endl;
}


The Output is...
number is 12
Now the value is 0
Now back in main again, the value of number is 12


Even though the parameter variable myValue is changed in the changeMe function, the argument number is not modified. The myValue variable contains only a copy of the number variable.

The changeMe function does not have access to the original argument. When only a copy of an argument is passed to a function, it is said to be passed by value . This is because the function receives a copy of the argument’s value and does not have access to the original argument.
I had done it like that before but i thought I was doing something wrong having so many declarations in one function. But is that considered okay since its a function with 3 sub functions.
I had done it like that before but i thought I was doing something wrong having so many declarations in one function.
This might be a design problem, but it's not as if you had a choice. All variables that you use have to be declared/defined.
Topic archived. No new replies allowed.