Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-17-2008, 10:17 AM
Member
 
Join Date: May 2008
Posts: 39
ayoood is on a distinguished road
Question
If i have this statement
For example:
If x1 equal to 12 and x2 equal to 5, then y is 3
So i use (if else) statement ???
In this programme i want to make this things when i press x1 some value and x2 some value that give me the result that i put it in the (if else ststement)
I don’t want anybody make the programme just i need to know the statement that i need it in this programme and how it done

Thank you for your helping
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 05-17-2008, 11:20 AM
sukatoa's Avatar
Senior Member
 
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 509
sukatoa is on a distinguished road
Send a message via Yahoo to sukatoa
I doubt about your statement....

Are you going to calculate first the two inputs?
and use it for comparison inside an if else statement?

or check the two inputs first? and try to search for a match pair?

could you post another detailed info about your algo?
__________________
A specific, detailed, simple, well elaborated, and "tested before asking" question may gather more quick replies. hopefully
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 05-17-2008, 11:54 AM
Member
 
Join Date: May 2008
Posts: 39
ayoood is on a distinguished road
Im going to do project about wireless router
I will give x1 type of signal and x2 type of signal and y is the output .I have all the statement I have just to programmed it I need to know which statement that im going to use it that when I enter signal type for x1 and signal type of signal of x2 I get the right answer
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 05-17-2008, 12:32 PM
sukatoa's Avatar
Senior Member
 
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 509
sukatoa is on a distinguished road
Send a message via Yahoo to sukatoa
If you can predict 99.99% the output by calculating the 2 input signals,

then you can use switch statement on it,
if statement is also applicable but it adds more lines of code..(for me)....
__________________
A specific, detailed, simple, well elaborated, and "tested before asking" question may gather more quick replies. hopefully
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 05-17-2008, 01:22 PM
Member
 
Join Date: May 2008
Posts: 39
ayoood is on a distinguished road
I know i tired you with me a ask a lot of question but this is the last question could you show me how does that written

If x1 is excellent and x2 low then y is almost good

Sorry about that
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 05-17-2008, 03:02 PM
sukatoa's Avatar
Senior Member
 
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 509
sukatoa is on a distinguished road
Send a message via Yahoo to sukatoa
Quote:
If x1 is excellent and x2 low then y is almost good
Code:
if((x1==excellent)&&(x2<=low)){ y="almost good"; }
__________________
A specific, detailed, simple, well elaborated, and "tested before asking" question may gather more quick replies. hopefully
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 05-18-2008, 04:23 PM
Member
 
Join Date: May 2008
Posts: 39
ayoood is on a distinguished road
import java.io.*;

public class Class1
{

public static void main (String [] args) throws java.io.IOException
{
int y;
int x1;
int x2;
int excellent;
int low;
int poor;
int verygood;
int good;
int nosignal;

System.out.println("Please enter x1");
System.out.println("Please enter x2");

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:");
}

}




Sorry about that bro I wrote it by myself be there are some of error so could you see what is the wrong with my code

Im really sorry about that
Bookmark Post in Technorati
Reply With Quote
  #8 (permalink)  
Old 05-18-2008, 05:07 PM
sukatoa's Avatar
Senior Member
 
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 509
sukatoa is on a distinguished road
Send a message via Yahoo to sukatoa
Quote:
int excellent;
int low;
int poor;
int verygood;
int good;
int nosignal;
you may initialize first some values above.

Quote:
System.out.println("Please enter x1");
System.out.println("Please enter x2");
You may read Scanner class for capturing inputs from keyboard... nextInt() method may fit your needs

Quote:
System.out.println("your type of signal is:");
How about concat(String s) method?

eg. System.out.println("Signal type is".concat(y));

or System.out.println("Signal type is"+y);
or System.out.printf("Signal type is %s\n",y); C type
__________________
A specific, detailed, simple, well elaborated, and "tested before asking" question may gather more quick replies. hopefully
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Last edited by sukatoa : 05-18-2008 at 05:11 PM.
Bookmark Post in Technorati
Reply With Quote
  #9 (permalink)  
Old 05-19-2008, 10:16 PM
Member
 
Join Date: May 2008
Posts: 39
ayoood is on a distinguished road
i don’t know really what i do i try to solve the error but i couldn’t i read the file scanner class but i don’t know what i do with it I’m sorry about that i know it’s my wrong but i hope you to help me to overcome this problem i have only two days to submit the programme
Bookmark Post in Technorati
Reply With Quote
  #10 (permalink)  
Old 05-20-2008, 03:40 AM
Eku Eku is offline
Senior Member
 
Join Date: May 2008
Location: Makati, Philippines
Posts: 175
Eku is on a distinguished road
Try changing the data type of variable y to
Code:
String y=null;
then out is:
Code:
System.out.println("your type of signal is: " + y);
__________________
Mind only knows what lies near the heart, it alone sees the depth of the soul.
Bookmark Post in Technorati
Reply With Quote
  #11 (permalink)  
Old 05-20-2008, 04:10 AM
sukatoa's Avatar
Senior Member
 
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 509
sukatoa is on a distinguished road
Send a message via Yahoo to sukatoa
Not using Scanner,

Code:
public class test{ public static void main(String args[]) throws Exception{ String y; 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((System.in.read(new byte[200])))); System.out.println("Please enter x2"); x2 = Integer.parseInt(String.valueOf((System.in.read(new byte[200])))); 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); } }

Using Scanner,
Code:
public class test{ public static void main(String args[]) throws Exception{ String y; 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(keyInput()); System.out.println("Please enter x2"); x2 = Integer.parseInt(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(){ return new java.util.Scanner(System.in).nextLine(); } }
Using Buffered IO
Code:
import java.io.BufferedReader; import java.io.InputStreamReader; public class test{ public static void main(String args[]) throws Exception{ String y; 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 some experiments on it....
__________________
A specific, detailed, simple, well elaborated, and "tested before asking" question may gather more quick replies. hopefully
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #12 (permalink)  
Old 05-20-2008, 12:08 PM
Member
 
Join Date: May 2008
Posts: 39
ayoood is on a distinguished road
I am unable to express thank very much the word and a few in your right Thank You deserve more than this word all the programmes compile with me , you're really creative

Thank you very much again
Bookmark Post in Technorati
Reply With Quote
  #13 (permalink)  
Old 05-21-2008, 06:19 AM
sukatoa's Avatar
Senior Member
 
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 509
sukatoa is on a distinguished road
Send a message via Yahoo to sukatoa
You're welcome,

Eku's reply is the very important part, in post #7, i think you've stuck because you couldn't see any output....

next time, if you want to have an experiment, you may plan first on how you will display the output....
(that's the only evident you can use to decide whether it's correct or wrong).
__________________
A specific, detailed, simple, well elaborated, and "tested before asking" question may gather more quick replies. hopefully
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #14 (permalink)  
Old 05-21-2008, 11:22 AM
Member
 
Join Date: May 2008
Posts: 39
ayoood is on a distinguished road
yes there are some of output i didn't get the right answer so what i should to do to get the right answer???
Bookmark Post in Technorati
Reply With Quote
  #15 (permalink)  
Old 05-21-2008, 11:34 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,408
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
What output you are expecting here.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
(Close on July 13, 2008)
Bookmark Post in Technorati
Reply With Quote
  #16 (permalink)  
Old 05-21-2008, 02:58 PM
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
Bookmark Post in Technorati
Reply With Quote
  #17 (permalink)  
Old 05-21-2008, 03:23 PM
sukatoa's Avatar
Senior Member
 
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 509
sukatoa is on a distinguished road
Send a message via Yahoo to sukatoa
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
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
a question slytheman Java Servlet 0 03-12-2008 05:11 AM
Need help on this question Deon New To Java 3 01-27-2008 04:58 PM
JNI question javaplus New To Java 0 12-24-2007 11:18 AM
Need help with a question please sonal New To Java 1 11-29-2007 10:17 PM
Question mark colon operator question orchid Advanced Java 3 04-30-2007 11:37 PM


All times are GMT +3. The time now is 04:19 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org