Thread: Question
View Single Post
  #17 (permalink)  
Old 05-21-2008, 03:23 PM
sukatoa's Avatar
sukatoa sukatoa is offline
Senior Member
 
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 540
Rep Power: 3
sukatoa is on a distinguished road
Send a message via Yahoo to sukatoa
Default
try it,

Code:
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>poor)){
y = "almost good" ;
}else if ((x1==excellent)&&(x2==poor)&&(x2>nosignal)){
y = "poor" ;
}else if ((x1==excellent)&&(x2<=nosignal)){
y = "no signal" ;
}else if ((x1==verygood)&&(x2>poor)){
y = " good" ;
}else if ((x1==verygood)&&(x2==poor)&&(x2>nosignal)){
y = "low" ;
}else if ((x1==verygood)&&(x2<=nosignal)){
y = "poor" ;
}else if ((x1==good)&&(x2>poor)){
y = "almost low" ;
}else if ((x1==good)&&(x2==poor)&&(x2>nosignal)){
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";
}
}
}
__________________
A specific, detailed, simple, well elaborated, and "tested before asking" question may gather more quick replies. hopefully
Reply With Quote