What is Fraction Reduction to Lowest Term? | Maths Explanation for Visual Basic Kids
Reducing fractions to their lowest terms is all about
removing every common factor between the numerator and
the denominator.
In this junior secondary Visual Basic tutorial, you'll learn how to simplify fractions using a custom module.
The Visual Basic code provided helps reduce fractions to their lowest terms by finding common factors between the numerator and denominator.
Whether you're a student or teacher, this math-focused Visual Basic project makes fraction simplification easy and fun.
How the Reduce Fraction to Lowest Term Method Works | Detailed Explanation for Visual Basic Kids
Let's see a Visual Basic algorithm implementation to reduce a fraction to it's lowest term, using 12/16 as an example fraction.
A common factor to 12 and 16 is 2;
so removing 2 from 12/16 yields
6/8.
Again, 2 is common to both 6 and 8;
removing it yields 3/4.
We stop when nothing else is common (1 does not count).
Create a new VB.Net class file; Project, Add Class.
Call it LowestTerm.vb.
Optionally, Create a new VB.Net module file; Project, Add Module.
Call it LowestTermModule.vb.
Type out the adjoining Visual Basic (VB.Net) codes for reducing fractions to their lowest terms.
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! Visual Basic Fun Practice Exercise - Reduce Fraction to Lowest Term
As a fun practice exercise, feel free to try out your own fractions with different numerators and denominators,
and see how the Visual Basic code simplifies those fractions.
VB.Net Code for Reducing Fractions to Lowest Term - Class File
Public Class LowestTerm
Dim numerator As Integer
Dim denominator As Integer
Dim trial_factor As Integer
Public Sub _init_(fraction As Dictionary(Of String, Integer))
numerator = fraction.Item("numerator")
denominator = fraction.Item("denominator")
If numerator < denominator Then
trial_factor = numerator
Else
trial_factor = denominator
End If
End Sub
Public Function reduceFraction() As Dictionary(Of String, Integer)
Do While trial_factor > 1
If numerator Mod trial_factor = 0 Then
If denominator Mod trial_factor = 0 Then
numerator = CInt(numerator / trial_factor)
denominator = CInt(denominator / trial_factor)
Continue Do
End If
End If
trial_factor -= 1
Loop
Dim send_back As New Dictionary(Of String, Integer)
send_back.Add("numerator", numerator)
send_back.Add("denominator", denominator)
Return send_back
End Function
End Class
VB.Net Code for Reducing Fractions to Lowest Term - Main Module
Module Algebra_LowestTerm
Sub Main()
Dim fraction As New Dictionary(Of String, Integer)
fraction.Add("numerator", 16)
fraction.Add("denominator", 640)
Console.WriteLine(" To reduce to lowest term, simplifying:")
Console.WriteLine(String.Format("{0,45}", fraction.Item("numerator")))
Console.WriteLine(String.Format("{0,45}", "-"))
Console.WriteLine(String.Format("{0,45}", fraction.Item("denominator")))
Dim low_term As New LowestTerm
low_term._init_(fraction)
fraction = low_term.reduceFraction()
Console.WriteLine(Environment.NewLine)
Console.WriteLine(String.Format("{0,46}", fraction.Item("numerator")))
Console.WriteLine(String.Format("{0,46}", "Answer = -"))
Console.WriteLine(String.Format("{0,46}", fraction.Item("denominator")))
End Sub
End Module