Created
September 11, 2017 20:31
-
-
Save GriffinG1/578894092390c712e745852ed07cb9d8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AddFractions extends ConsoleProgram | |
{ | |
public void run() | |
{ | |
int numFirst = readInt("What is the numerator of the first fraction? "); | |
int denFirst = readInt("What is the denominator of the first fraction? "); | |
int numSecond = readInt("What is the numerator of the second fraction? "); | |
int denSecond = readInt("What is the denominator of the second fraction? "); | |
int numTotal = ((numFirst * denSecond) + (denFirst * numSecond)); | |
int denTotal = (denFirst * denSecond); | |
System.out.print("The sum of " + numFirst + "/" + denFirst + " + " + numSecond + "/" + denSecond + " = " + numTotal + "/" + denTotal); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment