how to use a scanner's input( used in a swtich case in main's body) in a
method('s body) defined outside the main
I am stuck in a code as I have used scanner class(system.in) multiple
times in a switch case in the main's and I have also declared a public
method before main, which need to take the argument from that scanner's
keyboard input. how can I access scanner values obtained in main method,
in a method declared outside the main?
below is a chunk of method's code before the main:
public class temp_cnvrter {
public static double cels(double input1) /* this input1 needs to be
fetched from scanner inside main method*/
{
double output1;
output1= input1 + 273.15;
System.out.println("temperature in rankine is:" +output1 );
return output1;
}
public static void main(String[] args) {
}
No comments:
Post a Comment