2 つのネストされたスイッチがあり、1 つのスイッチ ケースの値を別のスイッチ ケースで使用したいと考えていました。以下の例のように、double 変数temp_usrを使用して、別の switch ケースのメソッド(cels())に引数として渡したいのですが、どうすればよいですか?
switch( switch1){
case 1:
{
System.out.println(" You have selected Celsius");
Scanner temp_ip= new Scanner(System.in);
System.out.println("Please enter the temperature in celsius");
double temp_usr= temp_ip.nextDouble();
}
break;
case 2: ...............
case 3: ...............
switch(switch2) {
case 1:
{
System.out.println("convert it into Celsius");
System.out.println(cels(arg)); /*this argument should take value of temp_usr*/
}
break;
case 2: .........
case 3: .........