Web Development

General discussion


Creating a Calculator

By rawle ·
Create the control instances on a calculator form. Code so that when the user presses one of the numeric buttons on the calculator, the value is appended to the label appearing at the top of the form. Write the statements to perform arithmetic operations on the current numbers. Each time an operation is performed, your solution should clear the contents of the current number label. Code should perform the following operations: addition (+), subtraction (-), multiplication (*), division (/), and equals (=), and needs to detect whether the operand is the first operand. Write the statements for the C button. This button should clear the contents of the number label and the tape label. Create error handlers as necessary to prevent all possible errors, including numeric overflow, numeric underflow errors in type conversion, and division by zero errors.
Create a menu for the form with a single menu title having a caption of Format. Create three menu items on the Format menu having captions of Background Colors, Text Colors, and Fonts.
Create an instance of the ColorDialog control on the form. When the user clicks the Background Colors button, set the background color of the two labels appearing on the form. When the user clicks the Text Colors button, set the text color of the Label control instances. Allow the user to define custom colors. Create an instance of the FontDialog on the form. When the user clicks the Fonts menu item, set the Font in the two labels to the font selected by the user.

I can send the executable by email if you need to look at what the form should look like.

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

by TheChas In reply to Creating a Calculator

I'm sorry, this sounds like a homework assignment.

If I'm wrong, I apologize in advance.

There are NUMEROUS examples of code for calculators posted on various web sites.

Just do a search on calculator emulators, and you should find at least enough to get you started.


Collapse -

by rawle In reply to

Poster rated this answer.

Collapse -

by rawle In reply to Creating a Calculator

This question was closed by the author

Related Discussions

Related Forums