Ask Question
12 July, 00:54

Define a method printfeetinchshort, with int parameters numfeet and numinches, that prints using ' and " shorthand. Ex: printfeetinchshort (5, 8) prints:

+3
Answers (1)
  1. 12 July, 01:47
    0
    Following is printfeetinchshort method in Java:

    void printfeetinchshort (int numfeet, int numinches)

    {

    System. out. println (numfeet + "/'"+numinches+"/"");

    }

    Explanation:

    In the above method escape character (/) is used to print single inverted comma (') and double inverted comma (") using / ' and / ".

    Following is the Java program to implement the above method:

    public class Main

    {

    public static void main (String[]args)

    {

    printfeetinchshort (5,8);

    }

    public static void printfeetinchshort (int numfeet, int numinches)

    {

    System. out. println (numfeet + "/'"+numinches+"/"");

    }

    }

    Following will be the output of above program:

    5'8"

    In the above program the method printfeetinchshort () is made as static so that it can called be by Main method directly and not through any object instantiation.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Define a method printfeetinchshort, with int parameters numfeet and numinches, that prints using ' and " shorthand. Ex: printfeetinchshort ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers