CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2010
    Posts
    4

    Question First Practice Program need help...C++

    Need help with simple code for calculating interest...not compound....yet. Can not figure out what code is needed to change the -double percent- to a -decimal-.

    Giving me a error:
    ------ Build started: Project: Practice_Work, Configuration: Debug Win32 ------
    Practice_Work.cpp
    Practice_Work.cpp(24): error C2440: '=' : cannot convert from 'System:ecimal' to 'double'
    No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
    ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

    Here is the Code i have written so far:

    // Practice_Work.cpp : main project file.
    // calculating intrest over one fixed period

    #using <mscorlib.dll>
    #include <iostream>
    using namespace System;
    using namespace std;

    int main()
    {

    //declaring variables

    double number= 0.0;
    double percent= 0.0;
    double difference= 0.0;
    double sum= 0.0;

    //Algorithms: assigning intergers to variables

    Console::WriteLine("Enter Amount: ");
    number= Convert::ToDouble(Console::ReadLine());
    Console::WriteLine("Enter Intrest Rate: ");
    percent= Convert::ToDouble(Console::ReadLine());
    percent= Convert::ToDecimal(percent);


    //Calculations for solving the algorithm

    difference= number*percent;
    sum= number + difference;

    //Printing out the results

    Console::WriteLine("Total amount after intrest equals: ",Convert::ToString(sum));


    cin.get();
    return 0;

    }

  2. #2
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,675

    Arrow Re: First Practice Program need help...C++

    The first thing I can tell from looking at your code is that it's C++/CLI rather than "just" C++. So you should rather post your question in the Managed C++ and C++/CLI forum (unless a moderator is faster and moves the entire thread over there).

    And when you do so, please use code tags which will significatly improve the readability of your code.

    See you over there...

    Ah, and... welcome to CodeGuru!
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

  3. #3
    Join Date
    Oct 2010
    Posts
    4

    Re: First Practice Program need help...C++

    OOPS haha Thanks for that help, I will move it to there. And thanks again, gad to finally join a forum.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured