In Java
Write program for printTable() taking an int type parameter which indicates # of rows
It is based on the following
Task Write a Java program where the main) method prompts the user to select an integer value between 1 and 30. Pass that value into a method called printTable). The printTable() method takes one int type parameter that is used to indicate the number of rows output in the table. Example: printTable(rows) i The printTable() method outputs the table lke this Pounds Kilograms 0.45 0.9 1.35 The basic loop can be found on page 43 of our Course Reader. Your mothod will have only one parameter (essentialy the \'stop* variable). Use two spaces between \"Pounds\" and \"Kilogram* and a tab character t*between the pounds and kilos variable outputs. Lab Submission 6.16.1: Lab 6d Due 17-Nov-16 Load default template.. File: Lab6d. java 1 import java.util.Scanner;
Hi, Please find my implementation.
Please let me know in case of any issue.
import java.util.Scanner;
public class Lab6d {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
// TODO: get user choice
System.out.print(\"Enter a integer (1-30) :\" );
int stop = scnr.nextInt();
//TODO: call print table
printTable(stop);
}
public static void printTable(int stop){
// TODO: heade
System.out.println(\"Pounds\\tKilograms\");
//TODO: loop
for(int pound=1; pound <=stop; pound++){
System.out.println(pound+\"\\t\"+(pound*0.45));
}
}
}
/*
Sample run:
Enter a integer (1-30) :10
Pounds Kilograms
1 0.45
2 0.9
3 1.35
4 1.8
5 2.25
6 2.7
7 3.15
8 3.6
9 4.05
10 4.5
*/