Ask Question
2 January, 11:08

Define a method printFeetInchShort, with int parameters numFeet and numInches, that prints using ' and " shorthand. End with a newline. Ex: printFeetInchShort (5, 8) prints:

+4
Answers (1)
  1. 2 January, 11:25
    0
    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 + "/"");

    }

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Define a method printFeetInchShort, with int parameters numFeet and numInches, that prints using ' and " shorthand. End with a newline. Ex: ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers