C#.NET Program 24

Output:

























Code:

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 Question_5
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        
        //Total Button
        private void button3_Click(object sender, EventArgs e)
        {
            if (Convert.ToInt32(textBox5.Text) >= 500 && Convert.ToInt32(textBox5.Text) <= 1000)
            {
                textBox6.Text = (Convert.ToInt32(textBox5.Text) * 5 / 100).ToString();
                textBox7.Text = (Convert.ToInt32(textBox5.Text) - Convert.ToInt32(textBox6.Text)).ToString();
            }
            else if (Convert.ToInt32(textBox5.Text) >= 1000 && Convert.ToInt32(textBox5.Text) <= 2000)
            {
                textBox6.Text = (Convert.ToInt32(textBox5.Text) * 10 / 100).ToString();
                textBox7.Text = (Convert.ToInt32(textBox5.Text) - Convert.ToInt32(textBox6.Text)).ToString();
            }
            else if (Convert.ToInt32(textBox5.Text) >= 2000 && Convert.ToInt32(textBox5.Text) <= 3000)
            {
                textBox6.Text = (Convert.ToInt32(textBox5.Text) * 15 / 100).ToString();
                textBox7.Text = (Convert.ToInt32(textBox5.Text) - Convert.ToInt32(textBox6.Text)).ToString();
            }
            else if (Convert.ToInt32(textBox5.Text) >= 3000 && Convert.ToInt32(textBox5.Text) <= 4000)
            {
                textBox6.Text = (Convert.ToInt32(textBox5.Text) * 20 / 100).ToString();
                textBox7.Text = (Convert.ToInt32(textBox5.Text) - Convert.ToInt32(textBox6.Text)).ToString();
            }
            else if (Convert.ToInt32(textBox5.Text) >= 4000 && Convert.ToInt32(textBox5.Text) <= 5000)
            {
                textBox6.Text = (Convert.ToInt32(textBox5.Text) * 25 / 100).ToString();
                textBox7.Text = (Convert.ToInt32(textBox5.Text) - Convert.ToInt32(textBox6.Text)).ToString();
            }
            else
            {
                textBox6.Text = (Convert.ToInt32(textBox5.Text) * 30 / 100).ToString();
                textBox7.Text = (Convert.ToInt32(textBox5.Text) - Convert.ToInt32(textBox6.Text)).ToString();
            }
        }
        
        //discount Button
        private void button2_Click(object sender, EventArgs e)
        {
            textBox5.Text = (Convert.ToInt32(textBox3.Text) * Convert.ToInt32(textBox4.Text)).ToString();
        }

        //Add Button
        private void button1_Click(object sender, EventArgs e)
        {
            textBox1.Enabled = false;
            textBox2.Clear();
            textBox3.Clear();
            textBox4.Clear();
            textBox5.Clear();
            textBox6.Clear();
            textBox7.Clear();
        }
    }
}

No comments:

Post a Comment