Block of Code

Practical Examples for Programmers

  • Home
  • C++
  • Java
  • Visual Basic
  • Discrete Math
  • Ask a Question

Fractions

Write a program for the fraction calculator shown in the figure below. After the numerators and denominators of the two fractions to the left of the equal sign are placed in the four text boxes, one of four operations should be clicked on. The result appears to the right of the equal sign. The program should use a calculator class, which contains three members of the type Fraction discussed in Exercise 28 of Section 11.1. Note: In the figure below, the fraction bars are very short list boxes.

BEFORE FINISHING THIS PAGE REMOVE THE REFERENCE TO EXERCISE 28 ABOVE.  ALSO CHANGE THE PICTURE TO REFLECT * AND /.

Fractions Screenshot

 

Suggested Control Names and Attributes:

Name Property Text Property Control Type Notes
 frmFractions Fractions Form Holds Controls
 txtNumerator1 TextBox Captures first numerator
 txtDenominator1 TextBox Captures first denominator
 btnAdd  + Button Triggers event to add fractions
 btnSubtract  – Button Triggers event to subtract fractions
 btnMultiply  * Button Triggers event to multiply fractions
 btnDivide  / Button Triggers event to divide fractions
 txtNumerator2 TextBox Captures second numerator
 txtDenominator2 TextBox Captures second denominator
 txtAnswerNumerator TextBox Displays numerator of answer *
 txtAnswerDenominator TextBox Displays denominator of answer *

Set the Read Only property to True.

Secondary Sidebar

This is the secondary sidebar

Copyright © 2023 · Metro Pro Theme on Genesis Framework · WordPress · Log in