Wrox Programmer Forums
|
VS.NET 2002/2003 Discussions about the Visual Studio.NET programming environment, the 2002 (1.0) and 2003 (1.1). ** Please don't post code questions here ** For issues specific to a particular language in .NET, please see the other forum categories.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VS.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 18th, 2006, 04:09 AM
Registered User
 
Join Date: Dec 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default MC++ quadratic equation problem

Hi, I'm doing a school project where I need to make a program to calulate the quadratic equation. Now, I already got that part taken care of with the following code:

#include "stdafx.h"
#include "math.h"
#include "stdlib.h"

#using <mscorlib.dll>

using namespace System;


int _tmain()
{
    String *firstnum,
        *secondnum,
        *thirdnum;

    double num1, num2, num3, answer, root, root2, answer1, answer2, complex, complex2, complex3;

    Console::Write(S"Enter the first number: ");
    firstnum = Console::ReadLine();

    Console::Write(S"Enter the second number: ");
    secondnum = Console::ReadLine();

    Console::Write(S"Enter the third number: ");
    thirdnum = Console::ReadLine();

    num1 = Int32::Parse(firstnum);
    num2 = Int32::Parse(secondnum);
    num3 = Int32::Parse(thirdnum);

    answer = num2*num2 - 4*num1*num3;

    if(answer == 0)
    {
        root = -num2/(2*num1);
        Console::WriteLine(S"\nThe answer is {0}.", root.ToString());
    }

    answer1 = sqrt(answer);

    if(answer > 0)
    {
        root2 = (-num2 + answer1) / (2*num1);
        Console::WriteLine(S"\nThe answer is {0}", root2.ToString());
        root2 = (-num2 - answer1) / (2*num1);
        Console::WriteLine(S"\nThe answer is {0}", root2.ToString());
    }

    answer2 = abs(answer);
    complex = sqrt(answer2);

    if(answer < 0)
    {
        complex2 = -num2 / (2*num1);
        complex3 = complex / (2*num1);

        Console::Write(S"\nThe answer is {0}", complex2.ToString());
        Console::Write(S"+{0}", complex3.ToString());
        Console::WriteLine(S"i");

        Console::Write(S"\nThe answer is {0}", complex2.ToString());
        Console::Write(S"-{0}", complex3.ToString());
        Console::WriteLine(S"i");
    }
    return 0;
}

But now I need to do this same thing by creating a GUI using textboxes and such. Now, I would have 3 textbox where the user would input the 3 numbers(num1, num2, num3), do the calulation, then display the answer into a 4th textbox. My problem is I'm not sure how to declare the textbox to equal to the num1, num2, and num3 that I have already used. I hope my question is understandable because I'm kinda new to this. Thanks in advance






Similar Threads
Thread Thread Starter Forum Replies Last Post
Solve Linear Equation in XSLT waqasnet XSLT 2 November 10th, 2008 02:34 PM
"Adding PHP to the Equation" Gregorio BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 3 July 5th, 2006 08:59 PM
Chapter 1 - Adding PHP to the Equation Chudz BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 7 June 22nd, 2005 11:32 AM
Adding php to the equation problem dreadzz BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 1 June 22nd, 2005 11:30 AM
String in mc++ question Ereinion Visual C++ 0 November 7th, 2003 11:44 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.