Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

ASP.NET MVC Create a much more interact calculator, one that functions like a normal calculator, e.g., the Windows calculator in standard mode. Again there should

ASP.NET MVC

Create a much more interact calculator, one that functions like a normal calculator, e.g., the Windows calculator in standard mode. Again there should be two overloaded controller methods (Index) but you only return a single view. On the first page, you will serve an HttpGet request of /Home/Index. The second page will serve an HttpPost request for the same page. I suggest using a single view model to store the operands, operator, and the result. To list multiple post submission buttons, you will need a form for each button. I suggest creating a new field called input that will represent what button was clicked. This time there wont be any text boxes, but instead you will use hidden data to pass the model to and from the controller. You can embed hidden data via an html helper as follows: @Html.HiddenFor(x => x.Operand0). If an operand is clicked, you will need to set the model to the operand. For instance, you can use the 9 key as follows: Model.Input = '9'; @Html.HiddenFor(x => x.Input) The controller will need to accept the input, decide what to do with it (if = it should run your Calculator class method), and output the result to the same Model View. Before an operator is clicked, you will need to append each operand to the operand property. For instance, if I wanted to input 19.1, I will need to click the 1 key, then the 9 key, then the . key, and finally the 1 key. Each character can be appended to the operand by using the += operator on a string. When sending hidden data via a post, the last post will always overwrite new data coming from a controller. For instance, if I send 19 as Operand0, along with the character ., your controller will update (append) the view modelss Operand0 with 19, and then pass this to the view. However, by default the input data from the last submission (coming in via the ModelState dictionary) will always overwrite any data coming from the controller, so you will still see 19. To get around this, within the controller, you need to remove any input from the ModelState dictionary AFTER you processed the input: ModelState.Remove("Operand0"); Another option is to clear the ModelState dictionary completely with: ModelState.Clear(); For full credit, your application should be able to operate on two operands. The following operands should work: */+-^. Also, a period . should allow for decimals. The first operand should be deliminated with an operator. The second operand should be delimited with an equals (=) sign. The c button should reset the calculator allowing the user to start back over. I will give 5 points extra credit if the user is able to continue using the calculator with more than two operands, e.g., 5+4-2. I will give 5 more points if you can keep clicking on the equals for a repeat operation, e.g., 3*2==== would equal 3*2*2*2*2=48. The picture below on the following page shows you what Im expecting the interface to look like.

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

Students also viewed these Databases questions

Question

What are DNA and RNA and what is the difference between them?

Answered: 1 week ago

Question

Why do living creatures die? Can it be proved that they are reborn?

Answered: 1 week ago

Question

1. Diagnose and solve a transfer of training problem.

Answered: 1 week ago