Ask Question
15 September, 05:49

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

+1
Answers (1)
  1. 15 September, 09:01
    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?
Find an answer to your question ✅ “Define a method printfeetinchshort, with int parameters numfeet and numinches, that prints using ' and " shorthand. Ex: printfeetinchshort ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers