211k views
5 votes
Project 1 - Calculator Construct a calculator that aceepts only INTEGER numbers, one digit at a time. The calculator will be able to add, subtract, divide and multiple any two integer numbers. In addition, the special buttons will compute the square root, the square an integer number, and a factorial. (Factorial: 4!=4×3×2×1=24 ) Clear Display Clears only the number just entered in the display. Clear All Clears all values in the current calculation and is ready to start a new calculation. Function Create a Function in a separate Module to process the buttons for 0 to 9 . The number in the display is computed in the program and placed in the display. This is accomplished by multiplying the display number by 10 and adding the new number based on the button selected. (Required a FUNCTION in a separate Module). Remember that 423=(4×1(00)+(2×10)+(3×1). Subroutine Use the Module with a Subroutine for the two number calculations that stores the value of the first numbers for,−x and i operations and sets up for the second number. Equal (= Button For the two number calculations, the cqual button (−) computes the value of the two numbers for,+=x and f. This requires that the SELECT CASE statement be used. Factorial Use a DO LOOP or FOR Stutement to compute the Factorial. VB Function Use the VB function to compute the Square Root for its button.

User Fully
by
8.2k points

1 Answer

7 votes

Final answer:

The student is tasked with creating a calculator program in Visual Basic that can perform basic arithmetic operations, calculate square roots, squares, and factorials, with a focus on implementing a function and a subroutine.

Step-by-step explanation:

The topic involves constructing a calculator that accepts integer inputs one digit at a time, with functionality to add, subtract, multiply, and divide numbers. A separate module should feature a function that incorporates digits into a display number (by multiplying the display number by 10 and adding the new digit).

Calculations for square roots will utilize the Visual Basic (VB function), and factorials will be computed using a DO LOOP or FOR statement. Special care must be taken in the subroutine within a module to accommodate the two-number calculations for arithmetic operations with the SELECT CASE statement used for determining the operation to perform when the Equal (=) button is pressed.

Care and understanding of number theory and operation control are critical to ensure accuracy, as calculators perform operations without guarding against issues like significant figures or rounding errors.

A function in a separate module should be created to process the buttons for numbers 0 to 9. The function should compute the result by multiplying the display number by 10 and adding the new number based on the button selected.

A subroutine with the module should be used for the two number calculations, which stores the value of the first number for addition, subtraction, and multiplication operations, and sets up for the second number. The equal (=) button computes the value of the two numbers based on the operation selected.

A DO LOOP or FOR Statement should be used to compute the factorial of a number. The VB function should be used to compute the square root for its button.

User MalloyDelacroix
by
7.9k points