Complete Question:
Define a method printFeetInchShort, with int parameters numFeet and numInches, that prints using ' and " shorthand. Ex: printFeetInchShort(5, 8) prints:
5' 8"
Hint: Use \" to print a double quote.
Answer:
public static void printFeetInchShort(int numFeet, int numInches) {
System.out.println(numFeet + "\'" + numInches + "\"");
}
Explanation:
The main idea here is the use of escape sequence to format our output the way we want it. A complete code is given below that calls this method and displays the output as required
public class NewQues {
public static void main(String[] args) {
int numFeet;
int numInches;
printFeetInchShort(5, 8);
System.out.println("");
return;
}
public static void printFeetInchShort(int numFeet, int numInches) {
System.out.println(numFeet + "\'" + numInches + "\"");
}
}