Click here to Skip to main content
Licence CPOL
First Posted 11 Mar 2008
Views 47,425
Downloads 2,955
Bookmarked 44 times

Scientific Calculator

By | 11 Mar 2008 | Article
Scientific calculator that calculates fibonacci modulo factorial sin cos tan.. you are able to also change background color and color of the buttons
Scientific_Calculator

Introduction

This is a scientific calculator that calculates fibonacci modulo factorial sin cos tan.. you are also able to change the background color and color of the buttons.

Using the Code

// using button number 1
private void button1_Click(object sender, EventArgs e)
{
    but_backspace.Enabled = true;        // number button is clicked, enable backspace
    but_backspace.BackColor = Color.LightCoral; // color button when enabled

    if (isOperation == true)          // if we used an operation clear output
        {textBox_output.Text = "";}   // empty output

    if (tempSign == "Sminus")
        { textBox_output.Text += "-1"; }

    else
        textBox_output.Text += "1";    // add 1 to output
        isOperation = false;           // no operation pressed yet
}

// using addition button
private void button12_Click(object sender, EventArgs e)
{
    if (textBox_output.Text == "")
    { // to prevent exception appearing
    }
    else
    {
        Operations.add(double.Parse(textBox_output.Text));
        textBox_output.Text = Convert.ToString(Operations.getResult());
        isOperation = true; // user pressed an operation
        tempSign = "plus";
    }
}

// factorial method
public static long factorial(long num)
{
    if(num >= 21 || num < 0)
    {
        MessageBox.Show("Enter number between 0 & 20",
        "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
        return 0;
    }
    else
    {
        if(num <= 1)
            return 1;
        else
            return num * factorial(num - 1); // recursive function
    }
}

History

  • 11th March, 2008: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Ramzi987654321

Software Developer

Liberia Liberia

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralNice Calculator Pinmemberle uyen16:53 14 Aug '11  
JokeChange "." for "," PinmemberÁngel Manuel García Carmona10:43 21 Dec '10  
NewsThank you PinmemberPouriya.GH13:27 27 Mar '10  
GeneralMy vote of 2 Pinmemberwmostafa20:24 22 Dec '09  
GeneralUseful PinmemberEthnica21:18 6 Nov '09  
GeneralBravo PinmemberElissar3:50 22 Mar '08  
GeneralExcellent Pinmemberabou el ror3:44 22 Mar '08  
Generaljust to let you know... [modified] Pinmvptoxcct4:53 11 Mar '08  
GeneralRe: just to let you know... PinmemberRamzi Abou Rahal4:55 11 Mar '08  
GeneralRe: just to let you know... Pinmvptoxcct4:57 11 Mar '08  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120517.1 | Last Updated 11 Mar 2008
Article Copyright 2008 by Ramzi987654321
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid