usingMaths.com
Demonstrating and showing pupils and students one application of Mathematics.







<< Previous Next >>

Code for Multiplying Fractions in Visual Basic (VB.Net)



Method of Multiplying Fractions

Multiplying fractions is pretty straightforward:
Cancel out all common factors between numerators and denominators, then multiply whatever is left numerator to numerator and denominator to denominator.



Algorithm Steps to Multiply Fractions in VB.Net:

If we have
                  4/9 x 21/8;

Step 1:

Find any common factor between any numerator and any denominator.

Step 2:

Cancel out any such common factor.

= X7
421
98
3 
Step 3:

Repeat Steps 1 & 2 recursively until there are no more common factors.

=1X 
47
38
 2
=7
6

Create a new class file; Project, Add Class.
Call it MultiplyFraction.vb.
Optionally, create a new module file; Project, Add Module.
Call it MultiplyFractionModule.vb.
Type out the adjoining Visual Basic (VB.Net) codes for multiplying fractions.



Note: You can instead comment out the VB.Net code in the main module from the previous lesson or simply continue from where it stopped.


So!

Feel free to try out your own set of numerators and denominators for fractional multiplication.









<< Previous Next >>