Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

import java.util.Scanner; public class Lab6d { public static void main(String[]

ID: 3941527 • Letter: I

Question

import java.util.Scanner;

public class Lab6d {
public static void main(String[] args) {
  
Scanner scnr = new Scanner(System.in);
// TODO: get user choice

  
// TODO: call printTable method passing choice as the parameter
  
}

public static void printTable(int stop) {
// TODO: print header
  
// TODO: loop to print table rows up to stop value
  
}

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); The printTable() method outputs the table like this The basic loop can be found on page 43 of our Course Reader. Your method will have only one parameter (essentially the "stop" variable). Use two spaces between "Pounds" and "Kilogram" and a tab character T between the pounds and kilos variable outputs.

Explanation / Answer

import java.util.Scanner;

public class Lab6d {
public static void main(String[] args) {
  
Scanner scnr = new Scanner(System.in);
System.out.println("enter integer between 1 and 30 : ");

int n=scnr.nextInt();

printTable(n);
  
}

public static void printTable(int stop) {
System.out.println("Pound Kilograms");
  
for(int i=1;i<=n;i++)

{

System.out.println(i+" "+i*0.45);

}
  
}