Computer Science, asked by ruchitamittal, 7 months ago

Rewrite the following set of if-else in terms of switch:

class mistakes1{
public void main() {
Scanner sc=new Scanner(System.in);
int num, calc;
System.out.println(“Enter a number “);
num=sc.nextInt();
if(num==5) {
calc = num * 25 – 20;
System.out.println(num + calc);
}
else
if(num = = 10){
calc = num * 25 – 15;
System.out.println(calc - num);
}
}//main
}//class

I need it urgent...plz ans, i will mark as brainliest

Answers

Answered by Anonymous
1

Answer:

public void main() {

Scanner sc=new Scanner(System.in);

int num, calc;

System.out.println(“Enter a number “);

num=sc.nextInt();

if(num==5) {

calc = num * 25 – 20;

System.out.println(num + calc);

}

else

if(num = = 10){

calc = num * 25 – 15;

System.out.println(calc - num);

}

}//main

}//class

Similar questions