Thread: Question
View Single Post
  #16 (permalink)  
Old 05-21-2008, 02:58 PM
ayoood ayoood is offline
Member
 
Join Date: May 2008
Posts: 39
ayoood is on a distinguished road
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class test{

public static void main(String args[]) throws Exception{
String y=null;
int x1;
int x2;
int excellent = 100;
int verygood = 75;
int good = 50;
int low = 20;
int poor = 10;
int nosignal = 0;

System.out.println("Please enter x1");
x1 = Integer.parseInt(String.valueOf((keyInput())));
System.out.println("Please enter x2");
x2 = Integer.parseInt(String.valueOf(keyInput()));

if((x1==excellent)&&(x2<=low)){
y = "almost good" ;
}else if ((x1==excellent)&&(x2<=poor)){
y = "poor" ;
}else if ((x1==excellent)&&(x2<=nosignal)){
y = "no signal" ;
}else if ((x1==verygood)&&(x2<=low)){
y = " good" ;
}else if ((x1==verygood)&&(x2<=poor)){
y = "low" ;
}else if ((x1==verygood)&&(x2<=nosignal)){
y = "poor" ;
}else if ((x1==good)&&(x2<=low)){
y = "almost low" ;
}else if ((x1==good)&&(x2<=poor)){
y = "almost good" ;
}else if ((x1==good)&&(x2<=nosignal)) {
y = "poor" ;
} else{
y = "no sgnal" ;
}

System.out.println("your type of signal is:" + y);
}

private static final String keyInput(){
try{
return new BufferedReader(new InputStreamReader(System.in)).readLine();
}catch(Exception e){
e.printStackTrace();
return "0";
}
}
}
Try to test it, have s
Reply With Quote