Ask Question
26 October, 21:54

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

+5
Answers (1)
  1. 26 October, 22:15
    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 & 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