string last = ""; bool minus = false; bool plus = false; bool divide = false; bool multiply = false; string memory = ""; public Form1() { InitializeComponent(); } private void button2_Click(object sender, EventArgs e) { if (textBox1.Text.Contains(",")) { return;

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

C#(Sharp): I made my code and design below. Anybody can help me some correction and add some design button and code. "Need to make C# step by step design and code "Calculator where make a calculator program that can do add, subtract, multiply, divide and square root. It should have a memory save/restore function for one number. There should be a way to set the number of fraction digits displayed".

 

 

  • Code:

  • 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 AktCalc

    {

    public partial class Form1 : Form

    {

    string last = "";

    bool minus = false;

    bool plus = false;

    bool divide = false;

    bool multiply = false;

    string memory = "";

    public Form1()

    {

    InitializeComponent();

    }

    private void button2_Click(object sender, EventArgs e)

    {

  • if (textBox1.Text.Contains(","))

    {

    return;

    }

    else

    {

    textBox1.Text += ",";

    }

    }

    private void button21_Click(object sender, EventArgs e)

    {

    last = textBox1.Text;

    multiply = true;

    }

    private void button3_Click(object sender, EventArgs e)

    {

    last = textBox1.Text;

    plus = true;

    }

    private void button5_Click(object sender, EventArgs e)

    {

    last = textBox1.Text;

    divide = true;

    }

  • private void button4_Click(object sender, EventArgs e)

    {

    last = textBox1.Text;

    minus = true;

    }

    // Equalls =

    private void button6_Click(object sender, EventArgs e)

    {

    if (minus)

    {

    decimal equals1;

    equals1 = Convert.ToDecimal(last) - Convert.ToDecimal(textBox1.Text);

    textBox1.Text = Convert.ToString(equals1);

    }

    if (plus)

    {

    decimal equals1;

    equals1 = Convert.ToDecimal(last) + Convert.ToDecimal(textBox1.Text);

    textBox1.Text = Convert.ToString(equals1);

    }

    if (divide)

    {

    decimal equals1;

  • equals1 = Convert.ToDecimal(last) / Convert.ToDecimal(textBox1.Text);

    textBox1.Text = Convert.ToString(equals1);

    }

    if (multiply)

    {

    decimal equals1;

    equals1 = Convert.ToDecimal(last) * Convert.ToDecimal(textBox1.Text);

    textBox1.Text = Convert.ToString(equals1);

    }

    }

    private void button16_Click(object sender, EventArgs e)

    {

    textBox1.Text = Convert.ToString(Math.Sqrt(Convert.ToDouble(textBox1.Text)));

    }

    private void button1_Click(object sender, EventArgs e)

    {

    memory = textBox1.Text;

    label1.Text = "M";

    }

    private void button10_Click(object sender, EventArgs e)

    {

    memory = "";

    label1.Text = "";

    }

  • private void button15_Click(object sender, EventArgs e)

    {

    textBox1.Text = memory;

    }

    private void button11_Click(object sender, EventArgs e)

    {

    textBox1.Text = "";

    multiply = false;

    plus = false;

    minus = false;

    divide = false;

    }

    private void button20_Click(object sender, EventArgs e)

    {

    textBox1.Text += "0";

    }

    private void button19_Click(object sender, EventArgs e)

    {

    textBox1.Text += "1";

    }

    private void button18_Click(object sender, EventArgs e)

    {

  • textBox1.Text += "2";

    }

    private void button17_Click(object sender, EventArgs e)

    {

    textBox1.Text += "3";

    }

    private void button14_Click(object sender, EventArgs e)

    {

    textBox1.Text += "4";

    }

    private void button13_Click(object sender, EventArgs e)

    {

    textBox1.Text += "5";

    }

    private void button12_Click(object sender, EventArgs e)

    {

    textBox1.Text += "6";

    }

    private void button9_Click(object sender, EventArgs e)

    {

    textBox1.Text += "7";

    }

  • private void button8_Click(object sender, EventArgs e)

    {

    textBox1.Text += "8";

    }

    }

    }

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education