retune and refine this code, 4 erros as of now ...

Visual Studio has 4 errors 1 warning showing right now, but there is prob more due to my sloppy code. Can anyone point out some of the errors.
1
2
3
4
5
6
7
8
9


#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;


Last edited on
Line 18 "price" is a double. Line 62 you try to pass it as an integer.

Price:
double price, disPercent, discountAmnt, discountPrice; //variables for discount function

Tried to pass price as an integer.
howMany(price, disPercent, fundsAvail, leftOver);

Parameter sets nbrOfItems as an integer.
void howMany(int nbrOfItems, double costItem, double fundsAvail, int &leftOver)

Line 129, price is undefined. You have price only existing in your main function, it does not cross over into your other functions as it is not global.
I see them.. They were all typos.
Last edited on
Now the errors are howmany: local definitions are illegal , mostDiscount: local definitions are illegal
Check your bracketing, this error means that you are trying to define a function inside of another function.

It would be like trying to define your "howmany" function inside of your main. C++ does not allow for that.

If you make sure your brackets are all correct and you are not defining functions inside of other functions, that error should go away. Just go one-by-one and make sure each opening bracket has an ending bracket appropriately placed.
That worked :-) now I have an error uninitialized local variable 'discountAmt' , uninitialized local variable 'nbrOfitems'

Does that mean I missed/forgot something too?
Never mind I solved it and am deleting the code above because it is an assignment for a university class.
Topic archived. No new replies allowed.