473,837 Members | 1,701 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

invalid operands of types `double ()(double)' an

1 New Member
I am having a problem with my program. I cant figure out a solution for the compiler error im getting.

In function `double endingConversio n(double)':
invalid operands of types `double ()(double)' and `double' to binary `operator*'

Please Help thanks.

Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <cmath>
  4. using namespace std;
  5.  
  6. const double BRITAINCONVERSION = 00.630676, // Conversion rate britain
  7.              MEXICOCONVERSION = 13.5584,     // mexico conversion rate
  8.              JAPANCONVERSION = 88.7626;      // Japan's conversion rate
  9.  
  10. //***function prototypes entered here
  11. int    showMenu();
  12. double americanDollarAmount(double americanCurrency);
  13. double conversionRate(int menuChoice);
  14. double showConversion(double);
  15. double endingConversion(double americanCurrency);
  16.  
  17. int main()
  18.     int menuChoice = 0;
  19.     double convertedCurrency = 0.0,        // Converted currency amount
  20.            americanCurrency = 0.0; 
  21.            //conversionType = 0.0;          
  22.  
  23.     //display output in fixed-point notation with two decimal places 
  24.     cout << fixed << setprecision(2) << showpoint;
  25.  
  26.     // Establish repetition to convert different amounts to 
  27.     // different foreign currencies until a menu choice to quit 
  28.     // the program is entered
  29.     do
  30.     { 
  31.         //*** Enter function call to the function that 
  32.         //*** displays the conversion menu.  
  33.         //*** Note:  This needs to be a value-returning function 
  34.  
  35.         menuChoice = showMenu();
  36.  
  37.  
  38.         if (menuChoice != 4) 
  39.         {
  40.             //***Enter function call for function that 
  41.             //***prompts, accepts & validates a dollar amount to convert 
  42.  
  43.             americanDollarAmount(americanCurrency);
  44.  
  45.             //***Enter function call for function that 
  46.             //***selects the conversion rate based upon 
  47.             //***menu selection
  48.  
  49.             conversionRate(menuChoice);
  50.  
  51.  
  52.             //***Enter function call to function that 
  53.             //***calculates the foreign currency amount
  54.             //***This function will require the dollar amount, and 
  55.             //***the conversion rate. It will also return the 
  56.             //***converted amount 
  57.  
  58.             endingConversion(americanCurrency);
  59.  
  60.             //***Enter function call to function that 
  61.             //***will display the converted currency information
  62.  
  63.         }
  64.  
  65.     }
  66.     while (menuChoice != 4);
  67.  
  68.        system("pause");
  69.        return 0;
  70. }
  71.  
  72. //Enter here:  Function to display menu choices and 
  73. //then get and validate menu choice
  74. //before returning it to the function call statement
  75. //Note:  menu choice will indicate the type of 
  76. //foreign currency conversion that the program 
  77. //needs to perform.
  78.  
  79. int showMenu()
  80. {
  81.  
  82.     int choice; 
  83.  
  84.     system("CLS");
  85.     cout << "\n\t\tForeign Currency Conversion Menu\n\n";
  86.     cout << "1. British pounds\n";
  87.     cout << "2. Mexican pesos\n";
  88.     cout << "3. Japanese yen\n";
  89.     cout << "4. Quit the Program\n\n";
  90.     cout << "Enter your choice of 1, 2, 3, or 4: ";
  91.  
  92.     cin >> choice;
  93.  
  94.     // Validate the menu selection.
  95.     while (choice < 1 || choice > 4)
  96.     {
  97.        cout << "Please enter 1, 2, 3, or 4: ";
  98.        cin >> choice;
  99.  
  100.     }
  101.  
  102.     return choice;    
  103. }
  104.  
  105.  
  106. //Enter Here:  Function to prompt for and get the 
  107. //American dollar amount.  Be sure to validate that 
  108. //it is not less than zero (0).  
  109.  
  110. double americanDollarAmount(double americanCurrency)
  111. {
  112.  
  113.    do
  114.      {
  115.             cout << "Enter the amount of American dollars to convert: ";
  116.             cin >> americanCurrency;
  117.  
  118.      }
  119.    while (americanCurrency <= 0);
  120.       {  
  121.         system("pause");
  122.        return 0;
  123.        }
  124.      return americanCurrency;
  125. }
  126.  
  127.  
  128.  
  129. //Enter Here:  Function to select the 
  130. //foreign currency conversion rate based 
  131. //upon a conversion type integer value 
  132. //provided via a parameter value 
  133. //provided from the call statement 
  134.  
  135. double conversionRate(int menuChoice)
  136. {
  137.  
  138.   switch (menuChoice)
  139.       {
  140.          case 1:  showConversion (BRITAINCONVERSION);
  141.                     break;
  142.         case 2:  showConversion (MEXICOCONVERSION);
  143.                     break;
  144.         case 3:  showConversion (JAPANCONVERSION);
  145.       }
  146.  
  147.      while (menuChoice != 4);
  148.  
  149. }
  150.  
  151.  
  152. //Enter Here:  Function to calculate the currency conversion
  153. //of dollars to a foreign currency given a conversion rate
  154. //Note:  The converted amount must be returned to the main 
  155. //method so that it can be provided to the function that is 
  156. //going to display the final conversion information 
  157.  
  158. double endingConversion(double americanCurrency)
  159. {
  160.     double finalConversion;
  161.  
  162.       finalConversion = showConversion * americanCurrency;
  163.  
  164. }
Apr 23 '11 #1
2 4999
whodgson
542 Contributor
I'm surprised that it compiles with return americanCurrenc y at the end of main(). If you enclosed your code in tags it would make it easier to read.
Apr 23 '11 #2
Banfa
9,065 Recognized Expert Moderator Expert
showConversion is declared as a function but you have just used its name resulting in a function pointer in the calculation.
Apr 23 '11 #3

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

Similar topics

12
9898
by: Sydex | last post by:
When I compile code I get error C2664: 'Integration::qgaus' : cannot convert parameter 1 from 'double (double)' to 'double (__cdecl *)(double)' in this part : double Integration::quad2d(double (*func)(double,double)) { nfunc = func ; return qgaus(f1,x1,x2);//error there
0
3707
by: Frank King | last post by:
Hi, I am using CArray and quick sort funciton to sort an array of double type of data points. I found an article in MSDN HOWTO: Quick Sorting Using MFC CArray-Derived Classes ID: Q216858 The article works well with CStringArray. But when I wrote the following code about double type. It does not work for
4
31392
by: muthu | last post by:
In the following code it gives the error "error: invalid operands to binary &" Why it is happening #include <signal.h> #include <errno.h> #define SIGBAD(signo) ((signo) <= 0 || (signo) >= NSIG) /* <signal.husually defines NSIG to include signal number 0 */
1
8230
by: JWest46088 | last post by:
I keep getting these error messages: area(double,double) in Rectangle cannot be applied to () return "Area: " + Rectangle.area() + "\tCircumference: " + Rectangle.perimeter(); ^ perimeter(double,double) in Rectangle cannot be applied to () return "Area: " + Rectangle.area() + "\tCircumference: " + Rectangle.perimeter(); ^ setSides(double,double) in Rectangle cannot be applied to (double)...
1
2774
by: Richard Eich | last post by:
gcc (GCC) 3.4.6 20060404 (Red Hat 3.4.6-3) source snippet: .... int i = 17 ; if ( 0x03 & i ) ....
11
16950
by: Spiros Bousbouras | last post by:
#include <stdlib.h> int main(void) { char **p1 ; const char **p2 ; p1 = malloc(5 * sizeof(char *)) ; if (p1 == 0) return EXIT_FAILURE ; p2 = p1 + 1 ; p2 - p1 ;
2
29712
by: xelloss | last post by:
#include<cstdlib> #include<iostream> #include<iomanip> #include<vector> #include<fstream> using namespace std; double sum(vector<double> x) { double total = 0.0;
5
7144
by: Sheldon | last post by:
Hi Everyone, I have defined a function: struct Transient arrFromHdfNode(HL_NodeList *nodelist, struct Transient retv); and in the code: struct Transient arrFromHdfNode(HL_NodeList *nodelist, struct
2
5810
by: Genro | last post by:
#include<stdio.h> #include<TX/graphics.h> #include<time.h> // I need help! struct Krug{ double _x; double _y; double _skox; double _skoy; double _granx1;
0
9846
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9685
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10886
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10580
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9413
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7817
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7007
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5674
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4479
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.