Computer Science, asked by sushma7648, 4 months ago

(c) Use switch case statement for the given if construct:
if(i==100)
c=i*2;
else if(i==200)
c=i* 4;
else if(i==600)
c=i*10​

Answers

Answered by srijashreedubey
6

Answer:

import java.util.*;

public class switch_

{

   public static void main (String args [])

   {

       Scanner s = new Scanner(System.in);

       

       System.out.println("Enter a number (100,200 & 600) --->");

       int i = s.nextInt();

       

       int c;  

       switch(i)

       {

           case 100 :  

           {

              c=i*2;

              System.out.println("the result is --->"+c);

              break;

             }

           case 200 :  

           {

              c=i*4;

              System.out.println("the result is --->"+c);

              break;

             }

           case 600 :  

           {

              c=i*10;

              System.out.println("the result is --->"+c);

              break;

             }

            default: System.out.println("WRONG INPUT");  

               

           }

       }

   }

       

Similar questions