By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,192 Members | 811 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,192 IT Pros & Developers. It's quick & easy.

Error compiling (function call?)

P: 4
Hi. I'm Alize. I'm taking Intro to Programming C++. I enjoy this class but sometimes I'm really bad with the programming I just cannot believe why do I do silly mistake.

Here are the instructions I've written for a question below

Winning Division
This program should calculate which division in a company had the greatest sales for a quarter. It should use the following functions:
1. A function should ask the user for and return the quarterly sales figures for the company's Northeast, Southeast, Northwest, and Southwest divisions.
2. A function should determine which division had the highest sales figures.
A message should be displayed indicating the leading division and its sales figures for the quarter.
Input Validation: Do not accept dollar amounts less than $0.00.

My instructions are as follows:
Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. //Function Prototypes.
  7.     void findHighest(float nE, float sE, float nW, float sW);
  8.  
  9.     int main()
  10. {
  11.  
  12. // For cin command.   
  13.     float nE, sE, nW, sW;
  14.  
  15.     nE = input_div( "North East" );    
  16.     sE = input_div( "South East" );    
  17.     nW = input_div( "North West" );    
  18.     sW = input_div( "South West" );    
  19.  
  20. // To print Results 
  21.     findHighest(nE, sE, nW, sW);
  22.  
  23.     return 0;    
  24. }
  25. **************************************************************************************
  26.     float input_div (nE, sE, nW, sW)
  27.     float sales;
  28. {
  29. do
  30. {
  31. // Get the sales for each division.
  32.    cout << "Enter the sales for " << North East << "Division: \n";
  33.    cin >> sales;
  34.    cout << "Enter the sales for " << South East << "Division: \n";
  35.    cin >> sales;
  36.    cout << "Enter the sales for " << North West << "Division: \n";
  37.    cin >> sales;
  38.    cout << "Enter the sales for " << North West << "Division: \n";
  39.    cin >> sales;
  40. }
  41. // Validate the Input.
  42. while (sales < 0)
  43. {
  44.    cout << "Amount cannot be less than $0.00, please try again: \n";
  45.    cin >> sales;
  46. }
  47. **************************************************************************************
  48.    void findHighest()
  49. {   
  50.    float highest, nE, sE, nW, sW;
  51.    string name; 
  52.  
  53. highest = nE    
  54. name = "North East";
  55.  
  56. if (sE > highest)
  57. {
  58. highest = sE;
  59. name = "South East";
  60. }
  61. if (nW > highest)
  62. highest = nW;
  63. name = "North West";
  64. }
  65. if (sW > highest)
  66. highest = sW;
  67. name = "South West";
  68. }
  69. cout << "The " << name << " division of the company had the highest ";
  70. cout << "sales of $ " << highest << ".";
  71. }
  72. return sales;
  73.  
I cannot compile this program WHYYYY Plz tell me. I've asked the teacher, read the chapter but there's something I don't know it's not clicking I'm so frustrated PLZZZ Experts help me. It's an intro class so the only codes I've used are covered other than that nothing advanced level!!
I'd remain thankful to all of u!!
Mar 22 '07 #1
Share this Question
Share on Google+
4 Replies


Expert 100+
P: 1,510
for a start you call the function input_div()
Expand|Select|Wrap|Line Numbers
  1.     nE = input_div( "North East" );    
  2.  
but don't define it
Mar 22 '07 #2

P: 4
for a start you call the function input_div()
Expand|Select|Wrap|Line Numbers
  1.     nE = input_div( "North East" );    
  2.  
but don't define it
Oh thanks. Ok i get this. That's the reason why I'm getting input_div undeclared. But when I try declaring input_div in the function header, it doesn't work. Wat would you suggest declaring it as:

I tried:

float input_div();

is there a problem still?
Mar 22 '07 #3

Expert 100+
P: 1,510
from the function call
Expand|Select|Wrap|Line Numbers
  1.     sW = input_div( "South West" );    
  2.  
I would expect the function header to be
Expand|Select|Wrap|Line Numbers
  1.     float input_div (const char * ch)
  2.  
however, further down the program you have
Expand|Select|Wrap|Line Numbers
  1.     float input_div (nE, sE, nW, sW)
  2.  
you have not specified what type the parameters are? I would guess float &
Mar 22 '07 #4

sicarie
Expert Mod 2.5K+
P: 4,677
I have changed the title of the thread to better describe the problem.
Mar 22 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.