Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

c++ errors in program

crosiecrosie Member Posts: 15
I keep getting the below errors in this training c++ program that converts dollars to 'DWORKS' from the minimum to the maximum dollars entered. Any ideas?
errors:
error C2593: 'operator <<' is ambiguous
error C2593: 'operator <<' is ambiguous
error C3861: 'setiosflags': identifier not found, even with argument-: error C3861: 'setprecision': identifier not found, even with argument-dependent lookup
error C3861: 'setw': identifier not found, even with argument-dependent lookup
error C3861: 'setw': identifier not found, even with argument-dependent lookup


//This program converts Dollars to DWORKS.

#include <iostream>
#include
#include


using namespace std;

int main()
{

double mindollars,counter;
double maxdollars;
const double step=.025;
const float dworksToDollar=27.00;

cout << setiosflags(ios::fixed) << setprecision(2);
cout<<"Enter mindollars to convert to DWORKS:
";
cin>>mindollars;
cout<<"Enter maxdollars to convert to DWORKS:
";
cin>>maxdollars;
cout << " Exchange Rates
"; //You are to display the exchange rate (27 to 1) at the top of the table
cout << " Dollars DWORKS
";
cout << " ------- ------
";

for (counter=mindollars;counter<maxdollars; counter=counter+step)
cout << setw(9) << mindollars << " " << setw(10) << (counter*dworksToDollar) << "
";

system("pause");


return 0;
}



Comments

  • stoberstober Member Posts: 9,765 ✭✭✭
    :
    : << (counter*dworksToDollar) << ;
    :

    and just what is that supposed to do? That is a typecast but typcasting what? Its very similar to this INCORRECT line

    << (int *) <<

  • crosiecrosie Member Posts: 15
    : :
    : : << (counter*dworksToDollar) << ;
    : :
    :
    : and just what is that supposed to do? That is a typecast but typcasting what? Its very similar to this INCORRECT line
    :
    : << (int *) <<
    :
    :

  • crosiecrosie Member Posts: 15
    I want to display a table of dollar conversion for each .25 from the min to the max dollars entered.

    example:

    dollars min $1
    dollars max $2

    dollars DWORKS
    1.00 2.00
    1.25 2.50
    1.50 3.00
    1.75 3.50
    2.00 4.00
  • stoberstober Member Posts: 9,765 ✭✭✭
    Oops! my apologizes. I misread that line of the program. Its not a typecast as I said -- it is multiplying two numbers. Your program compiles ok with my compiler VC++ 6.0. The output isn't correct because it is displaying the wrong variable. See below

    [code]
    cout << setw(9) << [red]counter [/red]<< " " << setw(10) << (counter*dworksToDollar) << "
    ";
    [/code]
  • crosiecrosie Member Posts: 15
    I credit myself as a slow learner. I've made the change that you mentioned and I still cannot compile in MS Visual Studio.NET 2003.

    error C3861 and C2593 on: cout << setiosflags(ios::fixed) << setprecision(2);

    I also get errors on all lines with setiosflags, setprecision and setw. Identifier not found.

    I appreciate your help!
  • DonotaloDonotalo Member Posts: 715
    : I credit myself as a slow learner. I've made the change that you mentioned and I still cannot compile in MS Visual Studio.NET 2003.
    :
    : error C3861 and C2593 on: cout << setiosflags(ios::fixed) << setprecision(2);
    :
    : I also get errors on all lines with setiosflags, setprecision and setw. Identifier not found.
    :
    : I appreciate your help!

    i've compiled and run the following code (slightly modified as mentioned stober and according to ur problem) and found no problem:
    [code]
    #include <iostream>
    #include
    using namespace std;

    int main()
    {

    double maxdollars, mindollars,counter;
    const double step=.25;
    const float dworksToDollar=27.00;

    cout << setiosflags(ios::fixed) << setprecision(2);
    cout<<"Enter mindollars to convert to DWORKS:
    ";
    cin>>mindollars;
    cout<<"Enter maxdollars to convert to DWORKS:
    ";
    cin>>maxdollars;
    cout << " Exchange Rates
    "; c
    cout << " Dollars DWORKS
    ";
    cout << " ------- ------
    ";

    for (counter=mindollars;counter<maxdollars; counter=counter+step)
    cout << setw(9) << counter << " " << setw(10) << (counter*dworksToDollar) << "
    ";

    return 0;
    }
    [/code]
  • stoberstober Member Posts: 9,765 ✭✭✭
    [b][red]This message was edited by stober at 2005-9-30 10:55:47[/red][/b][hr]
    I just copy-past your original program into a .NET 2003 C++ win32 console app and it compiled ok. The only change I made was remove the line shown below because stdafx.h should be surrounded by quotes not angle brackets and must be the first include file listed in the program.
    [code]
    #include
    [/code]


  • crosiecrosie Member Posts: 15
    Thank you both for your help! It now will compile in VS.NET 2003. You've made my weekend!
Sign In or Register to comment.