mplement the process co change as the program advances At th
mplement the process co change as the program advances. At this point, you will take input from the user in the while loop and send it to the process command. d) process Command(String input) e) To pass checkpoint 1, your input will need to return the input given 2) Check Point 2: 20 points (Due: Friday 12/9) This check point is intended to: a) Before writing code in netbeans, go to section 8 of this document and write pseudocode describing how to do part b. b) Implement the process fraction method. This method will take the users input fraction String and return it as a String in either improper fraction or proper fraction form. The String needs to be in Integer form [ex: 4 returns 4/1], Il Fraction Form lex 5/43 returns 5/4, 6/4 returns 6/4] or ll) Mixed fraction form [ex 1.2/3 returns 5/3). c) processFraction (String frac) d) You only need to worry about positive numbers at this time (negative numbers are handled in check point 3) e) Make sure to CoMMENT on the intention of the Process Fraction method 3) Check Point 3: 30 points (Due Fri 12/16) This check point is intended to: a) Before writing code in netbeans, go to section 8 of this document and write pseudocode describing how to do part b d. b) Change Process Fraction to accept negative values. c) Change Process Fraction to reduce the fraction. a. To do this the GCF function (Euclid\'s method) will be given in class. This is a pretty cool algorithm t will be given the day check point 2 is due b. Implement the Convert To output method to accept a String and return a proper whole number, proper fraction or mixed fraction in String form
Solution
Here goes the required method implementation of ProcessCommand
Code:
//processCommand method will process the input string and checks if the string is an integer
//or fraction or mixed fraction and calculates the output accordingly
public static String processCommand(String input){
if(!input.contains(\"/\")) {
input=input+\"/1\";
} else{
if(input.contains(\"_\")){
int a=parseInt(input.split(\"_\")[0]);
int d=parseInt(input.split(\"/\")[1]);
int n=parseInt(input.split(\"_\")[1].split(\"/\")[0]);
int num=d*a+n;
input=num+\"/\"+d;
}
}
return input;
}
Explanation:
