C#2
C#2
using System;
class Program
{
static void Main()
{
Console.Write("Enter unit price:$ ");
double unitPrice = Convert.ToDouble(Console.ReadLine());
double discountRate = 0;
namespace WindowsFormsApplication5
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
if (radioButton1.Checked)
result = length * width;
else if (radioButton2.Checked)
result = 2 * (length + width);
else
{
MessageBox.Show("Please select an option.");
return;
}
class Area
{
public double Base { get; set; }
public double Height { get; set; }
public double Radius { get; set; }
}
class Program
{
static void Main()
{
Triangle triangle = new Triangle();
Console.Write("Enter base of triangle: ");
triangle.Base = double.Parse(Console.ReadLine());
namespace WindowsFormsApplication6
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
double a = double.Parse(textBox1.Text);
double b = double.Parse(textBox2.Text);
double c = double.Parse(textBox3.Text);
double discriminant = b * b - 4 * a * c;
if (discriminant > 0)
{
double root1 = (-b + Math.Sqrt(discriminant)) / (2 * a);
double root2 = (-b - Math.Sqrt(discriminant)) / (2 * a);
textBox4.Text = root1.ToString();
textBox5.Text = root2.ToString();
}
else if (discriminant == 0)
{
double root = -b / (2 * a);
textBox4.Text = root.ToString();
textBox5.Text = "Same as Root1";
}
else
{
textBox4.Text = "No real solution";
textBox5.Text = "No real solution";
}
}
private void button2_Click(object sender, EventArgs e)
{
textBox1.Clear();
textBox2.Clear();
textBox3.Clear();
textBox4.Clear();
textBox5.Clear();
}
private void button3_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
}