This program uses C# in Visual Studio. Create an ATM ASP Web Form with the follo
ID: 3816474 • Letter: T
Question
This program uses C# in Visual Studio.
Create an ATM ASP Web Form with the following functionality:
1. First Page is a log in page with ID and Password and button. Only accept 'Sommerfeldt' as the ID and 'Instructor' as the password. If correct, go to main menu screen.
2. Main Menu screen - have 3 options:
1. Withdraw
2. Deposit
3. Quit
Sommerfeldt has an initial balance of $1000.00, so display this somewhere on the screen.
If he chooses option 1 (withdraw), ask for the amount to withdraw (cannot be over the balance), then deduct this amount from balance and display the balance. Re-display the menu.
If he chooses option 2 (deposit), ask for the amount to deposit, then add this amount to the balance and display the balance. Re-display the menu.
If he chooses option 3, quit the program.
Explanation / Answer
mainMenu.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class mainMenu : System.Web.UI.Page
{
double balance = 1000;
double amount;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
amount = Convert.ToDouble(TextBox1.Text);
balance = balance - amount;
TextBox2.Text = balance.ToString();
}
protected void Button2_Click(object sender, EventArgs e)
{
amount = Convert.ToDouble(TextBox3.Text);
balance = balance + amount;
TextBox2.Text = balance.ToString();
}
protected void Button3_Click(object sender, EventArgs e)
{
Response.Redirect("default.aspx");
}
}
mainMenu.aspx
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
Initial Balance = $1000.00<br />
<br />
<br />
<asp:Button ID="Button1" runat="server"
Text="1. Withdraw" />
<asp:Label ID="Label1" runat="server"
Text="Enter the amount and then click Withdraw"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<br />
<asp:Button ID="Button2" runat="server"
Text="2.Deposit" />
<asp:Label ID="Label2" runat="server"
Text="Enter the amount and then click Deposit"></asp:Label>
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
<br />
<br />
<asp:Button ID="Button3" runat="server" Text="3.Quit" />
<br />
<br />
Balance =
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<br />
<br />
click on the option of yout choice...<br />
</div>
</form>
</body>
</html>
default.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
if (TextBox1.Text == "Sommerfeldt" && TextBox2.Text == "Instructor")
Response.Redirect("mainMenu.aspx");
else
Label3.Text = "Invalid id or password. try again";
}
}
default.aspx
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<asp:Label ID="Label1" runat="server" Text="Enter ID"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<br />
<br />
<asp:Label ID="Label2" runat="server" Text="Enter Password"></asp:Label>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<br />
<br />
<asp:Button ID="Button1" runat="server" Text="Button" />
<asp:Label ID="Label3" runat="server" Text="Label"></asp:Label>
<br />
<br />
</asp:Content>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.