Web Development

General discussion

Locked

New To Programming - Calculator Functions

By ·
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.

5 total posts (Page 1 of 1)
Thread display: Collapse - | Expand +

All Comments

Collapse -
by In reply to New To Programming - Calc ...

ok what you attempting to do is called object orientated programming OOP. As such You first design the form with the needed look and make sure to initialize form values to a predetermined starting condition.

Number keys must access the currentvaluelabel object and right justify the number to the label.
you need a flag that starts out as false and remains false until + - / * = are used then it toggles to true. If true when a number key is pressed current value is cleared before opperation

For + - / * an operation flag is checked (orig 0) if 0 the value is copied to term1
if 1 (+) value is added to term1 from currentvalue
if 2 (-) value is subbed
if 3 (/) value is divided by term1 term1 = result
*** only if value is non-zero
if 4 (*) value is multi by term1 = term1
then set new new op flag and clear flag's

get the idea??

regards
rick

Collapse -
by In reply to

Poster rated this answer.

Collapse -
by In reply to New To Programming - Calc ...

What happened to the good ole days when you had to do your homework yourself? Kids these days.

Collapse -
by In reply to

Poster rated this answer.

Collapse -
by In reply to New To Programming - Calc ...

This question was closed by the author

Back to Web Development Forum
5 total posts (Page 1 of 1)

Related Discussions

• 17

tcavadias ·

• 9

tcavadias ·

• 0

Have you heard of Wooberly?

joebrian014 ·

• 11

hsingh91 ·

• 16

What is Importance of Website Design and Web Development

sumanbeltech ·