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







<< Previous Next >>

Code for Converting an Improper Fraction to Mixed Fraction in Visual Basic (VB.Net)



Fractional Numbers

As before, fractional numbers can either be Proper (e.g. 2/5), Improper (e.g. 5/2), or Mixed (e.g. 21/2),


Improper to Mixed Fraction Code in Visual Basic (VB.Net)

Say we have the fraction 10/3 - which is an improper fraction - we can convert this fraction to a mixed fraction by following a number of steps:

Step 1:

Find the largest number smaller than the numerator (10), that can divide the denominator - 3 - without remainder.
         ⇒ 9

Step 2:

Subtract the found number (9) - from Step 1 - from the numerator (10)
         ⇒ 10 - 9 = 1;
This yields the whole number.

Step 3:

Divide the found number (9) - from Step 1 - by the denominator (3)
         ⇒ 9/3 = 3;
This yields the new numerator.

Step 4:

Reuse the denominator (3) to get our mixed fraction
         ⇒ 31/3

Create a new class file; Project, Add Class.
Call it ImproperToMixed.vb.
Optionally, create a new module file; Project, Add Module.
Call it ImproperToMixedModule.vb.
Type out the adjoining Visual Basic (VB.Net) code for converting improper to mixed 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 numerator and denominator.









<< Previous Next >>