Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C# I need to Create a new WEB SITE with the following:- Create a webpage that contains server side directives, code declaration blocks, includes

In C# I need to Create a new WEB SITE with the following:-

  1. Create a webpage that contains server side directives, code declaration blocks, includes and controls.
  2. Create a simple calculator the contains four labels, three textboxes, six buttons and a list box:
  3. The first label = enter first number
  4. The second label= enter second number
  5. The third label = should display the result
  6. Four of the buttons should be "+", "-", "*", "/"
  7. The result textbox should be read only
  8. The startup page must be named index.
  9. Display a message indicating cannot divide by when the user click / and there is a zero the in the second box
  10. Prevent the user from entering text in the number fields
  11. Create the other two buttons
    1. store data - The store data will store the results into array
    2. display data - The display data will display the contents of the array (use 10 for the array size)

I need some help with steps 9 11 on the server side for the C# website.

Heres what I have so far for the C# website and code behind:

Index.aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Index.aspx.cs" Inherits="Calculator.Index" %>

Welcome to the C# Calculator!



Index.aspx.cs:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

namespace Calculator

{

public partial class Index : System.Web.UI.Page

{

double dec1stNum;

double dec2ndNum;

double decResult;

protected void Page_Load(object sender, EventArgs e)

{

}

protected void btnAdd_Click(object sender, EventArgs e)

{

//Accepts input from txt1stNum & txt2ndNum

double.TryParse(txt1stNum.Text, out dec1stNum);

double.TryParse(txt2ndNum.Text, out dec2ndNum);

//'Adds the 1st & 2nd numbers & displays the results

decResult = dec1stNum + dec2ndNum;

txtResult.Text = dec1stNum + " + " + dec2ndNum + " = " + decResult;

}

protected void btnSubtract_Click(object sender, EventArgs e)

{

//Accepts input from txt1stNum & txt2ndNum

double.TryParse(txt1stNum.Text, out dec1stNum);

double.TryParse(txt2ndNum.Text, out dec2ndNum);

//Subtracts the 2nd number from the 1st number & displays the results

decResult = dec1stNum - dec2ndNum;

txtResult.Text = dec1stNum + " - " + dec2ndNum + " = " + decResult;

}

protected void btnMultiply_Click(object sender, EventArgs e)

{

//Accepts input from txt1stNum & txt2ndNum

double.TryParse(txt1stNum.Text, out dec1stNum);

double.TryParse(txt2ndNum.Text, out dec2ndNum);

//Multiplies the 1st & 2nd numbers & displays the results

decResult = dec1stNum * dec2ndNum;

txtResult.Text = dec1stNum + " X " + dec2ndNum + " = " + decResult;

}

protected void btnDivide_Click(object sender, EventArgs e)

{

//Accepts input from txt1stNum & txt2ndNum

double.TryParse(txt1stNum.Text, out dec1stNum);

double.TryParse(txt2ndNum.Text, out dec2ndNum);

//Divides the 1st number by the 2nd number & displays the results

decResult = dec1stNum / dec2ndNum;

If dec2ndNum = 0;

Then;

txtResult.Text = dec1stNum + " / " + dec2ndNum + " = " + decResult;

End If;

}

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Larry Ellison Database Genius Of Oracle

Authors: Craig Peters

1st Edition

0766019748, 978-0766019744

More Books

Students also viewed these Databases questions

Question

Use the quadratic formula to solve each equation. -2t (t + 2) = -3

Answered: 1 week ago

Question

1. Identify and control your anxieties

Answered: 1 week ago