0% found this document useful (0 votes)
28 views3 pages

Assignment 4 (OOP)

The document contains code for a C# Windows Forms application that calculates discounts on amounts. Form1 contains a button click event that opens Form2. Form2 contains textboxes and buttons to enter an amount, calculate the discount percentage based on the amount, display the discount amount and total after discount. It calculates a 20% discount for amounts over 500, 15% discount for amounts between 250-500, and 10% discount for amounts between 100-250.

Uploaded by

Madan lal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views3 pages

Assignment 4 (OOP)

The document contains code for a C# Windows Forms application that calculates discounts on amounts. Form1 contains a button click event that opens Form2. Form2 contains textboxes and buttons to enter an amount, calculate the discount percentage based on the amount, display the discount amount and total after discount. It calculates a 20% discount for amounts over 500, 15% discount for amounts between 250-500, and 10% discount for amounts between 100-250.

Uploaded by

Madan lal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

[Type text]

Assignment # 4
Code: Form 1
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 Discountapp
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Button1_Click(object sender, EventArgs e)


{
Discount_form discount = new Discount_form();
discount.Show();
}
}
}

Code: Form 2
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 Discountapp
{
public partial class Discount_form : Form
{
double Amount, discount = 0;
public Discount_form()
{
InitializeComponent();
}

private void Button2_Click(object sender, EventArgs e)


{
Application.Exit();
}
[Type text]

private void Button1_Click(object sender, EventArgs e)


{
double discount_amount, total;
Amount = Convert.ToDouble(textBox1.Text);
if (Amount >= 500)
discount = 20;
else if (Amount < 500 && Amount >= 250)
discount = 15;
else if (Amount < 250 && Amount >= 100)
discount = 10;
discount_amount = (Amount * discount) / 100;
textBox3.Text = discount_amount.ToString();
total = Amount - discount_amount;
textBox2.Text = discount.ToString() + "%";
textBox4.Text = total.ToString();
}

private void Discount_form_Load(object sender, EventArgs e)


{

}
}
}

Output:
[Type text]

You might also like