Q:

Java - switch Statement

0

This Program is used to demonstrate switch concept.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import java.io.*; 

class ssvswitch 
{ 
public static void main(String arg[]) throws IOException 
{ 
String t,t1; 
double allo=0; 
int inc,cat; 
double all; 


DataInputStream dr = new DataInputStream(System.in); 

System.out.print("Enter the Income : "); 
t = dr.readLine(); 
inc = Integer.parseInt(t); 

System.out.print("Enter the Category : "); 
t1 = dr.readLine(); 
cat = Integer.parseInt(t1); 

switch(cat) 
{ 
case 1 : allo = 0.05; 
break; 

case 2 : allo = 0.07; 
break; 

case 3 : allo = 0.10; 
break; 
} 

all = inc * allo; 
System.out.println("\nAllowance to be paid : " + all); 
} 
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now