Question: So currently I now have only one error: using System; using System.Collections.Generic; using System.Windows.Forms; namespace ProjectedRaisesGUI { public partial class Form 1 : Form {

So currently I now have only one error:
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace ProjectedRaisesGUI
{
public partial class Form1 : Form
{
private readonly Label lblCurrentSalary;
private readonly TextBox txtCurrentSalary;
private readonly Button btnCalculate;
private readonly Label lblResult;
public Form1()
{
InitializeComponent();
lblCurrentSalary = new Label();
txtCurrentSalary = new TextBox();
btnCalculate = new Button();
lblResult = new Label();
lblCurrentSalary.Text = "Current Salary:";
lblCurrentSalary.Location = new System.Drawing.Point(10,20);
lblCurrentSalary.AutoSize = true;
txtCurrentSalary.Location = new System.Drawing.Point(150,20);
txtCurrentSalary.Width =100;
btnCalculate.Text = "Calculate";
btnCalculate.Location = new System.Drawing.Point(10,60);
btnCalculate.Click += new EventHandler(BtnCalculate_Click);
lblResult.Location = new System.Drawing.Point(10,100);
lblResult.AutoSize = true;
this.Controls.Add(lblCurrentSalary);
this.Controls.Add(txtCurrentSalary);
this.Controls.Add(btnCalculate);
this.Controls.Add(lblResult);
this.Text = "Projected Salary Calculator";
this.StartPosition = FormStartPosition.CenterScreen;
this.Size = new System.Drawing.Size(300,200);
}
private void BtnCalculate_Click(object sender, EventArgs e)
{
try
{
double currentSalary = Convert.ToDouble(txtCurrentSalary.Text);
double increaseRate =0.04; //4% increase rate
double projectedSalary = currentSalary *(1+ increaseRate);
lblResult.Text = $"New Salary: ${projectedSalary:F2}";
}
catch (FormatException)
{
MessageBox.Show("Please enter a valid number for the salary.", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
[STAThread]
private static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
public override bool Equals(object obj)
{
return obj is Form1 form &&
EqualityComparer.Default.Equals(lblResult, form.lblResult);
}
}
}
Code above:
Severity Code Description Project File Line Suppression State
Error (active) CS0017 Program has more than one entry point defined. Compile with /main to specify the type that contains the entry point.
And I can't figure out why. This is for the button specifically so I can get it to work, but it won't. Please help

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!