Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Console Application, Program to Add, Subtract, Multiply, Divide, Mod 2 numbers.

ID: 3784799 • Letter: C

Question

Console Application, Program to Add, Subtract, Multiply, Divide, Mod 2 numbers. In this program, you are going to create a C# Console Application that will ask the user to input a number (decimal). Then when they click enter they will be asked for a second number. Your program will then add both numbers, subtract them, multiply, divide and mod both numbers displaying the outputs in a neatly formatted way like this: If they enter a 0 as the second number then inform them that you cannot perform a division by zero (nor can you perform modulo by zero.) Ask them if they would like to input more numbers. If they say 'y' then the screen will be cleared and they will again be asked for two numbers in the same fashion as before. Otherwise the program will end. Don't worry about any error checking. Assume proper input.

Explanation / Answer

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

namespace Arithmetic
{
    public partial class ArthOperations : Form
    {
        public ArthOperations()
        {
            InitializeComponent();
            textBox3.Enabled = false;
        }
        private void add(object sender, EventArgs e)
        {
            float first;
            float second;
            float output;       
           first = Convert.ToInt32(textBox1.Text);    
           second = Convert.ToInt32(textBox2.Text);
           output = first + second;
           textBox3.Text=(output.ToString());
        }

          private void sub(object sender, EventArgs e)
       {
            float first;
            float second;
            float output;
            first = Convert.ToInt32(textBox1.Text);
            second = Convert.ToInt32(textBox2.Text);
            output = first - second;
            textBox3.Text = (output.ToString());
       }

         private void div(object sender, EventArgs e)
        {
            float first;
            float second;
            float output;
            first = Convert.ToInt32(textBox1.Text);
            second = Convert.ToInt32(textBox2.Text);
            output = first / second;
          textBox3.Text = (output.ToString());
        }

        private void mul(object sender, EventArgs e)     {
            float first;
          float second;
            float output;
            first = Convert.ToInt32(textBox1.Text);
            second = Convert.ToInt32(textBox2.Text);
            output = first * second;
            textBox3.Text = (output.ToString());
        }

        private void clear(object sender, EventArgs e)
        {
            textBox1.Text = "";
            textBox2.Text = "";
            textBox3.Text = "";

        }
    }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote