views:

53

answers:

3

\a3.cpp(75): error C2563: mismatch in formal parameter list

im certain im passing the fuction checkout with 3 doubles, i dont know why im getting the error i am. Please help

#include <iostream>
#include <cstdlib>
using namespace std;

 const double peanut_PRICE = 1.80;
 const double peanut_SHIP = 0.50;
 const double BOOK_PRICE = 9;
 const double BOOK_SHIP = 1.06;
 const double MOVIE_PRICE = 13.99;
 const double MOVIE_SHIP = 0.05;

 double checkout (double myamountofbooks, double myamountofmovies, double mypoundsofpeanuts)
 {
  myamountofbooks = myamountofbooks * (BOOK_PRICE + BOOK_SHIP);
  myamountofmovies = myamountofmovies * MOVIE_PRICE * (1 + MOVIE_SHIP);
  mypoundsofpeanuts = mypoundsofpeanuts * (peanut_PRICE + peanut_SHIP);
  return (myamountofbooks + myamountofmovies + mypoundsofpeanuts);

 }

 bool validUserImput (int whereUserWantsToGoNext)
 {

  if (whereUserWantsToGoNext > 50 || whereUserWantsToGoNext < 0)
   return false;
  else return true;

 }

 bool validUserImput (double whereUserWantsToGoNext)
 {

  if (whereUserWantsToGoNext > 50 || whereUserWantsToGoNext < 0)
   return false;
  else return true;

 }

int main()
{
 //===========================Declaration Statements==================================
 double amountofbooks = 0;
 double amountofmovies = 0;
 double poundsofpeanuts = 0;
 int whereUserWantsToGoNext = 0;


  while (! (whereUserWantsToGoNext == 4) ) 
  {
   cout << "1. Books\n2. Peanuts\n3. Movies\n4. Checkout\n" << endl;
   cin >> whereUserWantsToGoNext; 
   if (!validUserImput(whereUserWantsToGoNext)) cout << "INVALID IMPUT" << endl;

   if (whereUserWantsToGoNext == 1){
    cout << "Please enter your number of books";
    cin >> amountofbooks;
    if (!validUserImput(amountofbooks)) cout << "INVALID IMPUT" << endl;
   }

   if (whereUserWantsToGoNext == 3){
    cout << "Now please enter the number of movies you've selected";
    cin >> amountofmovies; 
    if (!validUserImput(amountofmovies)) cout << "INVALID IMPUT" << endl;
   }

   if (whereUserWantsToGoNext == 2) {
    cout << "Please enter the weight(in pounds) of your peanuts";
    cin >> poundsofpeanuts;
    if (!validUserImput(poundsofpeanuts)) cout << "INVALID IMPUT" << endl;
   }
   if (validUserImput == 4) cout << "Total Cost is..." << checkout(amountofbooks, amountofmovies, poundsofpeanuts);
  }
 cin >> amountofbooks;
 }
+2  A: 

The last if - you are comparing function pointer to an integer. try this:

if (validUserImput(3) == 4) cout << "Total Cost is..." << checkout(amountofbooks, amountofmovies, poundsofpeanuts);
VJo
You beat me to it = /
rlb.usa
`validUserImput` returns a boolean
Charles Salvia
@Charles Salvia validUserImput is a function that takes int as an argumentm and returns a bool. If you call it like it is called in the example, it is a function pointer of type bool (*)(int), not a call to the function validUserImput
VJo
+2  A: 

The problem is here:

if (validUserImput == 4) ...

validUserImput is a function, but you are not calling that function, you are trying to compare it to 4.

If you wanted to keep track of the number of valid inputs you received, you could instead add a new variable that you manually increment on every valid input.

sth
+1  A: 

I assume you want to display the result of the checkout function if the user selects 4. So you probably wanted to write:

   if (whereUserWantsToGoNext == 4) cout << "Total Cost is..." << checkout(amountofbooks, amountofmovies, poundsofpeanuts) << endl;
Charles Salvia