Define a method printFeetInchShort, with int parameters numFeet and numInches

Define a method printFeetInchShort, with parameters int numFeet and numInches, which prints using the abbreviation ‘ and “. End with a new line. Ex: printFeetInchShort(5, 8) displays: 5’ 8”

Define a printFeetInchShort method, with int numFeet and numInches parameters


Answer

import java.util.Scanner;

public class HeightPrinter {

    public static void printFeetInchShort(int numFeet, int numInches) {
        System.out.println(numFeet + "' " + numInches + """);
    }

    public static void main(String[] args) {
        Scanner scnr = new Scanner(System.in);
        int userFeet;
        int userInches;

        userFeet = scnr.nextInt();
        userInches = scnr.nextInt();

        printFeetInchShort(userFeet, userInches); // Will be run with (5, 8), then (4, 11)
    }
}

Related Posts
C Programming – Define stubs for the functions called by the below main().

Programming in C – Define stubs for the functions called by main() below.

Write the printItem() method for the base class. Sample output for below program:

Write the printItem() method for the base class. Sample output for the program below:

Complete the method definition to output the hours given minutes. Output for sample program: 3.5

Complete the method definition to output the given times to minutes. Output to sample program: 3.5

Write a method printshampooinstructions() with int parameter numcycles and void return type

Write a method printshampooinstructions() with int parameter numcycles and return type void

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *