Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Introduction The goals of this assignment are for you to: Practice working with Form controls and using the Form designer to develop a simple UI

Introduction
The goals of this assignment are for you to:
Practice working with Form controls and using the Form designer to develop a simple UI.
Develop an app by handling control events and applying the correct logic in response.
What you need to do
To complete this in-class assignment you need to do all of the following:
Complete the task as described below
Submit your solution (by midnight of the day of your assignment) as a single zip file to the eConestoga dropbox for the assignment so that ultimately I can associate a grade with it.
Share your solution (again as a single zip file) with the student that has been randomly assigned to be your peer-grader.
Grade the solution, and provide feedback on it, to the student that you have been randomly assigned to grade. To do this you will use a Microsoft Form as a means of submitting the grade and code review feedback to me. See eConestoga for the link to that form for this in-class assignment. Please submit your grade and feedback by midnight the day of the assignment.
Peer-marking Details
First of all, please review the details of the peer-grading-rules document. It is available at the top level of the In-class-assignments folder in eConestoga.
Also, I used a small Python program that randomly generated pairings for this in-class assignment and the resulting Excel spreadsheet that provides these pairings is included in the eConestoga folder for this assignment. Please consult this spreadsheet to know who you are peer-grading and who is peer-grading your solution.
Finally, please use the Microsoft Form linked to in the eConestoga folder for this assignment to submit your grade and feedback to the student you have been randomly assigned to grade.
Your Task
Your task for this assignment is to build a calculator app. One simple way for a calculator to work is as follows:
you enter the x(or 1st operand) value
select an operator (i.e.+,-,*, or /)
enter the y(or 2nd operand) value
and click =. It computes and displays the result in the textbox.
This means the app needs to remember the x value and the pending operator until you click the "=" sign. Use the following steps to implement a basic calculator app...
Steps:
1. Disable the textbox so that the number keys are the only way to enter operands.
2. You need 3 private Form variables:
a. x, which is the first operand
b. pendingOperation, the operator to be applied between x and the next number
c. isNewNumber, which is true when = has put a result into the textbox, and false as soon as a digit is clicked.
3. When a digit or decimal point is clicked (note: these can all use the same event handler):
a. If isNewNumber is true, clear the textbox & equation label, set isNewNumber to false
b. Cast sender to a Button so you can append its Text to the textbox: i.e.((Button)sender).Text
c. Ignore a second decimal place if the textbox already has one.
4. The operator buttons move the textboxs value to x, clears the textbox, and sets pendingOperation to the operator displayed on the button. Again, these can all use the same event handler.
5. The = buttons event handler has a switch (or a compound if-elseif), applying the pendingOperation between x (stored) and y (in the textbox).
a. The result is placed in the textbox & appended to the label, x is set to zero, pendingOperation is cleared, and isNewNumber is set to true.
6. The 12/5=2.4 label above the textbox is obvious, right? The main question is not how... its when... i.e. when are operands and operators appended to it? And when is it cleared?
7. C and CE (which is short for clear entry) both clear the textbox, while C also clears the label above the textbox, then sets x to zero, pendingOperation to , and isNewNumber to true.

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

Database And Transaction Processing

Authors: Philip M. Lewis, Arthur Bernstein, Michael Kifer

1st Edition

0201708728, 978-0201708721

More Books

Students also viewed these Databases questions

Question

Evaluate the integral. /2 cosx sin x dx

Answered: 1 week ago