0% found this document useful (0 votes)
142 views

MarkSheet & Calculator Program PDF

This C# code defines the logic for a graphical calculator application. It includes event handler methods for each number and operation button that update the textbox display. Variables track the first and second entered numbers, selected operation, and result. The equals button method performs the calculation based on the stored operation and updates the display with the result.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
142 views

MarkSheet & Calculator Program PDF

This C# code defines the logic for a graphical calculator application. It includes event handler methods for each number and operation button that update the textbox display. Variables track the first and second entered numbers, selected operation, and result. The equals button method performs the calculation based on the stored operation and updates the display with the result.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Coding Of Calculator Project

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Graphical_Calculator
{

public partial class Form1 : Form


{
int countdot;
String operations;
double fnum;//first num
double sndum;//secondnum
double result;
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
countdot++;
if (countdot == 1)
{
textBox1.Text = textBox1.Text + ".";
}
else
{
textBox1.Text = "invalid insertion";
}
}

private void n1_Click(object sender, EventArgs e)


{
if (textBox1.Text == "0" && textBox1.Text != null)
{
textBox1.Text = "1";
}
else
{
textBox1.Text = textBox1.Text + "1";
}
}

private void n2_Click(object sender, EventArgs e)


{
if (textBox1.Text == "0" && textBox1.Text != null)
{
textBox1.Text = "2";
}
else
{
textBox1.Text = textBox1.Text + "2";
}
}

private void n3_Click(object sender, EventArgs e)


{
if (textBox1.Text == "0" && textBox1.Text != null)
{
textBox1.Text = "3";
}
else
{
textBox1.Text = textBox1.Text + "3";
}
}

private void n4_Click(object sender, EventArgs e)


{
if (textBox1.Text == "0" && textBox1.Text != null)
{
textBox1.Text = "4";
}
else
{
textBox1.Text = textBox1.Text + "4";
}
}

private void n5_Click(object sender, EventArgs e)


{
if (textBox1.Text == "0" && textBox1.Text != null)
{
textBox1.Text = "5";
}
else
{
textBox1.Text = textBox1.Text + "5";
}
}

private void n6_Click(object sender, EventArgs e)


{
if (textBox1.Text == "0" && textBox1.Text != null)
{
textBox1.Text = "6";
}
else
{
textBox1.Text = textBox1.Text + "6";
}
}

private void n7_Click(object sender, EventArgs e)


{
if (textBox1.Text == "0" && textBox1.Text != null)
{
textBox1.Text = "7";
}
else
{
textBox1.Text = textBox1.Text + "7";
}
}

private void n8_Click(object sender, EventArgs e)


{

if (textBox1.Text == "0" && textBox1.Text != null)


{
textBox1.Text = "8";
}
else
{
textBox1.Text = textBox1.Text + "8";
}
}

private void n9_Click(object sender, EventArgs e)


{
if (textBox1.Text == "0" && textBox1.Text != null)
{
textBox1.Text = "9";
}
else
{
textBox1.Text = textBox1.Text + "9";
}
}

private void n0_Click(object sender, EventArgs e)


{
textBox1.Text = textBox1.Text + "0";
}

private void bclear_Click(object sender, EventArgs e)


{
textBox1.Text = "0";
countdot = 0;
}

private void bdiv_Click(object sender, EventArgs e)


{
/* if (operations == "/")
{
if (sndum == 0)
{
textBox1.Text = "Undefined";
}
else
{
fnum = Double.Parse(textBox1.Text);
textBox1.Text = "0";
operations = "/";
}

}*/
}

private void badd_Click(object sender, EventArgs e)


{
fnum = Double.Parse(textBox1.Text);
textBox1.Text = "0";
operations = "+";
countdot = 0;
}

private void bsub_Click(object sender, EventArgs e)


{
fnum = Double.Parse(textBox1.Text);
textBox1.Text = "0";
operations = "-";
countdot = 0;
}

private void bmul_Click(object sender, EventArgs e)


{
fnum = Double.Parse(textBox1.Text);
textBox1.Text = "0";
operations = "*";
countdot = 0;
}
private void button2_Click(object sender, EventArgs e)
{

fnum = Double.Parse(textBox1.Text);
textBox1.Text = "0";
operations = "/";
countdot = 0;

private void bequals_Click(object sender, EventArgs e)


{

sndum = Double.Parse(textBox1.Text);
if (operations == "+")
{
result = (fnum + sndum);
textBox1.Text = Convert.ToString(result);
fnum = result;
}
if (operations == "*")
{
result = (fnum * sndum);
textBox1.Text = Convert.ToString(result);
fnum = result;
}
if (operations == "-")
{
result = (fnum - sndum);
textBox1.Text = Convert.ToString(result);
fnum = result;
}
if (operations == "/")
{
result = (fnum / sndum);
textBox1.Text = Convert.ToString(result);
fnum = result;
}
}

private void bdiv_Click_1(object sender, EventArgs e)


{

private void Form1_Load(object sender, EventArgs e)


{

/* private void button2_Click(object sender, EventArgs e)


{

}*/
}
}

OUTPUT
CODING OF MARKSHEET PROJECT

OUTPUT

You might also like