Calling functions assistance please:)

Calling functions in main are getting errors saying too few arguments in call please help.


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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#include <iostream>
using namespace std;

const int CUPS_IN_A_PINT = 2;
const int CUPS_IN_A_QUART = 4;
const int CUPS_IN_A_GALLON = 16;

void ConvertTo (  int totalcups, int & gals, int & quarts, int & pints, 
                int & cups  );

// DO_02:  Write the function prototype for Display		 
	
void Display (int totalcups, int gals, int quarts, int pints, int cups );

void TotalUp ( int totalcups, int & festivalCups );                   

int main ( )
{

   int cider;
   int gallons, quarts, pints, cups;
   int totalGals, totalQts, totalPts, totalCps;
   int totalCider = 0;
   int days = 0;

   cin >> cider;

   while ( ! cin.eof ( ) )
   {
      // DO-3  Call the function ConvertTo passing the number
      //       of cups of cider entered, and returning the
      //       conversion of those cups to gallons, quarts,
      //       pints and cups.
		ConvertTo( cider ) ;
      
      days ++;
      cout << "The amount sold on day " << days << " was: ";
      Display ( cider, gallons, quarts, pints, cups );
      cout << endl;
      // DO-4  Call the function TotalUp to add the cups of
      //       cider entered to the total amount of cider
      //       sold during the festival.
		TotalUp( cider );
      
      cin >> cider;
   }
   // DO-5  Call the function ConvertTo a second time passing the 
   //       total number of cups sold at the festival and returning
   //       the total gallons, quarts, pints and cups 
	ConvertTo( totalCps );
   
   cout << endl;
   cout << "The total amount of cider sold at the festival was: ";
   Display ( totalCider, totalGals, totalQts, totalPts, totalCps);
   return 0;
}

//-----------------------------------------------------------------------
// This function converts the number of cups into the number of gallons, 
//      quarts, pints and cups.
// Hint: see the code below for names of parameters AND the prototype.    
// params: (in, out, out, out, out)                         
//-----------------------------------------------------------------------

// DO-6:  Complete the function header (Hint: see the prototype.)
void ConvertTo (    int totalcups, int & gals, int & quarts, int & pints, int & cups )
{
    int leftOverCups = totalcups;
    gals = leftOverCups / CUPS_IN_A_GALLON;
    leftOverCups = leftOverCups % CUPS_IN_A_GALLON ;
    quarts = leftOverCups / CUPS_IN_A_QUART;
    leftOverCups = leftOverCups % CUPS_IN_A_QUART ;
	
	// DO-7  Complete the calculations for pints and cups
	 pints = leftOverCups / CUPS_IN_A_PINT ;
	 leftOverCups = leftOverCups % CUPS_IN_A_PINT ;
	 cups = leftOverCups;
	

}

//-----------------------------------------------------------------------
// This function will display total cups and the break down of gallons, quarts,
//      pints and cups.   
// params: ( in, in, in, in, in )                         
//-----------------------------------------------------------------------

void Display (int totalcups, int gals, int quarts, int pints, int cups )
{
   cout << totalcups << " total cups of cider." << endl;
   cout << gals << " gallons, " << quarts << " quarts, "
      << pints << " pints, and " << cups << " cups of cider." << endl;
}



//-----------------------------------------------------------------------
// This function will add the amount of cider sold that day to a running total 
//      of cider sold for the festival.    
// params: (in, inout)                         
//-----------------------------------------------------------------------

void TotalUp ( int totalcups, int & festivalCups )
{
   // DO-8  Write the calculation that will add the first parameter
   //       to the second.
   
	totalcups += festivalCups;
}
Last edited on
Please edit your post and make sure your code is [code]between code tags[/code] so that it has line numbers and syntax highlighting, as well as proper indentation.

You forgot to ask a question.
Last edited on
it says the calling functions have too few arguments in the call
Please copy and paste the exact error message and indicate which line it is referring to.
closed account (48T7M4Gy)
line 34 says : ConvertTo( cider ) ;
but line 66 which says :
void ConvertTo(int totalcups, int & gals, int & quarts, int & pints, int & cups)
The problem you have it requires all those extra pieces of information in addition to the value for cider.

Same problem with your TotalUp function and call to it at line 43

1
2
3
4
// DO-3  Call the function ConvertTo passing the number
		//       of cups of cider entered, and returning the
		//       conversion of those cups to gallons, quarts,
		//       pints and cups. 


ConvertTo(cider, gallons, quarts etc);

Last edited on
closed account (48T7M4Gy)
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#include <iostream>
using namespace std;

const int CUPS_IN_A_PINT = 2;
const int CUPS_IN_A_QUART = 4;
const int CUPS_IN_A_GALLON = 16;

void ConvertTo(int totalcups, int & gals, int & quarts, int & pints,
	int & cups);

// DO_02:  Write the function prototype for Display		 

void Display(int totalcups, int gals, int quarts, int pints, int cups);

void TotalUp(int totalcups, int & festivalCups);

int main()
{

	int cider;
	int gallons, quarts, pints, cups;
	int totalGals, totalQts, totalPts, totalCps;
	int totalCider = 0;
	int days = 0;

	cin >> cider;

	while (!cin.eof())
	{
		// DO-3  Call the function ConvertTo passing the number
		//       of cups of cider entered, and returning the
		//       conversion of those cups to gallons, quarts,
		//       pints and cups.
		ConvertTo(cider, gallons, quarts, pints, cups);

		days++;
		cout << "The amount sold on day " << days << " was: ";
		Display(cider, gallons, quarts, pints, cups);
		cout << endl;
		// DO-4  Call the function TotalUp to add the cups of
		//       cider entered to the total amount of cider
		//       sold during the festival.
		//TotalUp(cider); // ******** Temporarily leave this out

		cin >> cider;
	}
	// DO-5  Call the function ConvertTo a second time passing the 
	//       total number of cups sold at the festival and returning
	//       the total gallons, quarts, pints and cups 
	//ConvertTo(totalCps); // ******** Temporarily leave this out


	cout << endl;
	cout << "The total amount of cider sold at the festival was: ";
	//Display(totalCider, totalGals, totalQts, totalPts, totalCps); // ******** Temporarily leave this out

	return 0;
}

//-----------------------------------------------------------------------
// This function converts the number of cups into the number of gallons, 
//      quarts, pints and cups.
// Hint: see the code below for names of parameters AND the prototype.    
// params: (in, out, out, out, out)                         
//-----------------------------------------------------------------------

// DO-6:  Complete the function header (Hint: see the prototype.)
void ConvertTo(int totalcups, int & gals, int & quarts, int & pints, int & cups)
{
	int leftOverCups = totalcups;
	gals = leftOverCups / CUPS_IN_A_GALLON;
	leftOverCups = leftOverCups % CUPS_IN_A_GALLON;
	quarts = leftOverCups / CUPS_IN_A_QUART;
	leftOverCups = leftOverCups % CUPS_IN_A_QUART;

	// DO-7  Complete the calculations for pints and cups
	pints = leftOverCups / CUPS_IN_A_PINT;
	leftOverCups = leftOverCups % CUPS_IN_A_PINT;
	cups = leftOverCups;


}

//-----------------------------------------------------------------------
// This function will display total cups and the break down of gallons, quarts,
//      pints and cups.   
// params: ( in, in, in, in, in )                         
//-----------------------------------------------------------------------

void Display(int totalcups, int gals, int quarts, int pints, int cups)
{
	cout << totalcups << " total cups of cider." << endl;
	cout << gals << " gallons, " << quarts << " quarts, "
		<< pints << " pints, and " << cups << " cups of cider." << endl;
}



//-----------------------------------------------------------------------
// This function will add the amount of cider sold that day to a running total 
//      of cider sold for the festival.    
// params: (in, inout)                         
//-----------------------------------------------------------------------

void TotalUp(int totalcups, int & festivalCups)
{
	// DO-8  Write the calculation that will add the first parameter
	//       to the second.

	totalcups += festivalCups;
}
Last edited on
Topic archived. No new replies allowed.