program errors

I'm trying to make a program to allow a user to enter the number of items and then the cost of each item to calculate the sales tax. I am getting a bunch of errors and I've worked on it for a really long time and can't figure out what the problems are/what the errors mean. Any help is appreciated


#include <iostream>
using namespace std;

//function prototype
double totalSales;
double salesTax;
double grandTotal;
void displayLine();
void displayHeader();
void displayBlanks();
void displayTotalSales (double total);
void displaySalesTax (double tax);
void displayDash();
void displayGrandTotal (double total);

int main()
{
//declare variables
double items = 0.0;
double amount = 0.0;
double rate = 0.0;
double taxRate = 0.0;
char another = 'Y';
do
{
cout << "How many sales items do you have?";
cin >> items;

for (double x = 1; x <= items; x=x+1)
{
cout << "Enter in the values of sales item" << x << endl;
cin >> amount;

totalSales = totalSales + amount;
} //end for


cout << "Enter in the sales tax percentage";
cout<< endl;
cout << "(Enter in 10 for 10%):";
cin >> rate;

//calculations
taxRate = rate/100;
salesTax = totalSales * taxRate;
grandTotal = totalSales + salesTax;

//display output items
displayLine();
displayHeader();
displayBlanks();
displayBlanks();
displayBlanks();
displayBlanks();
displayTotalSales (totalSales);
displaySalesTax (salesTax);
displayDash();
displayGrandTotal (grandTotal);
displayBlanks();
displayBlanks();
displayLine();

cout <<"Do you want to run this program again? (Y/N?):";
cin >> another;

}while(toupper(another)== 'Y');

return 0;

} //end of main function

//**********function definitions***********
void displayLine()
{
cout <<"********************************************:"<< endl;
} //end of displayLine function

void displayHead
{
cout<<"******** S A L E S R E C E I P T ********"<<endl;
} //end of displayHeader function

void displayBlank
{
cout << "** **";
} //end of displayBlanks

void displayTotalSales (double total)
{
cout<<"** Total Sales $ "<< total << " **"<<endl;
}//end of displayTotalSales

void displaySalesTax (double tax)
{
cout<<"** Sales Tax $ "<< tax << " **"<<endl;
} //end of displaySalesTax

void displayDash
{
cout<<" --------------------- "<<endl;
}//end of displayDash

void displayGrandTotal (double final)
{
cout<<"** Grand Total $ "<< final << " **"<<endl;
}//end of displayGrandTotal
Your first problem is that some of your functions do not have () placed after them. Such as void displayBlank on line 83. Go through and double check all of the functions are set up correctly like that.

Sometimes your function prototypes at the top, the functions you are calling in main, and the functions themselves do not have the exact same name.
For example your function is called void displayBlank but you call it displayBlanks everywhere else. (This happens with a few of them). Make sure everything matches up.

Everything else should work once those are fixed.

so what errors are you getting? what does the compiler say?
oh and please use the code tags;D
Last edited on
I added the () after the functions and when I clicked compile after that it said 0 errors.

But then, when I hit run it says 3 errors that I've never seen before and have no idea what they mean..


--------------------Configuration: Homework4 - Win32 Debug--------------------
Linking...
Homework4.obj : error LNK2001: unresolved external symbol "void __cdecl displayBlanks(void)" (?displayBlanks@@YAXXZ)

Homework4.obj : error LNK2001: unresolved external symbol "void __cdecl displayHeader(void)" (?displayHeader@@YAXXZ)

Debug/Homework4.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.

Homework4.exe - 3 error(s), 0 warning(s)


Sometimes your function prototypes at the top, the functions you are calling in main, and the functions themselves do not have the exact same name.
For example your function is called void displayBlank but you call it displayBlanks everywhere else. (This happens with a few of them). Make sure everything matches up.


That is why. You need to make sure your function names stay consistent throughout the entire code (which right now they aren't).
I see declaration of displayHead in the original code. So you shall correctly name this function in its definition. The same valid and for displayBlanks because it was named as displayBlank (without ending 's') in the definition.
Last edited on
Wow thank you all so much! It was a very silly mistake with an easy fix.

Thanks!
Topic archived. No new replies allowed.