import javautilScanner public class Lab6d public static voi

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.

Solution

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\\tKilograms\");
  
for(int i=1;i<=n;i++)

{

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

}
  
}

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

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site