Results 1 to 9 of 9
- 05-31-2010, 04:31 PM #1
Member
- Join Date
- May 2010
- Posts
- 3
- Rep Power
- 0
for Loop with Yes/No Question! help..please!
Wer i can put my next code if i press "Y" the program will proceed to the next day of loop and i can not enter Time in and Time out but if i Press "N".. i can continue enter Timein and Timeout then proceed to the next day of loop?
Please help!!!
This is my codes....
Java Code:import java.io.*; public class DayLoop { public static void main(String[]args) throws Exception { BufferedReader read = new BufferedReader (new InputStreamReader(System.in)); String empDays[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday"}; String holiday=""; int tin=0,tout=0; for (int cnt=0;cnt<empDays.length;cnt++) { System.out.println("======================="); System.out.println("Today is " +empDays[cnt]); System.out.println("======================="); System.out.print("Is "+empDays[cnt]); System.out.println(" a Holiday? Y/N"); holiday = read.readLine(); System.out.println("***********************"); System.out.println("Enter Time-in: "); tin = Integer.parseInt(read.readLine()); System.out.println("Enter Time-out: "); tout = Integer.parseInt(read.readLine()); } } }Last edited by Eranga; 05-31-2010 at 05:16 PM. Reason: code tags added
- 05-31-2010, 04:39 PM #2
Maybe you should go to the basics tutorial: http://java.sun.com/docs/books/tutor...lts/index.html
Java Code:for (int cnt=0;cnt<empDays.length;cnt++) { System.out.println("======================="); System.out.println("Today is " +empDays[cnt]); System.out.println("======================="); System.out.print("Is "+empDays[cnt]); System.out.println(" a Holiday? Y/N"); holiday = read.readLine(); if(holiday.equals("Y")){ System.out.println("***********************"); System.out.println("Enter Time-in: "); tin = Integer.parseInt(read.readLine()); System.out.println("Enter Time-out: "); tout = Integer.parseInt(read.readLine()); } }Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
The Ubiquitous Newbie Tips
- 05-31-2010, 04:53 PM #3
as phHein told,u do...apat from this u just add this holiday.trim().equalsIgnoreCase() to be safe
Ramya:cool:
- 05-31-2010, 05:19 PM #4
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
- 06-01-2010, 04:28 AM #5
Member
- Join Date
- May 2010
- Posts
- 3
- Rep Power
- 0
That's Good
But i need more inputs if i press "N" in keyboard the program will continues and i start enter time-in and time-out...
- 06-02-2010, 12:52 PM #6
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
- 06-02-2010, 03:09 PM #7
Member
- Join Date
- May 2010
- Posts
- 3
- Rep Power
- 0
nope., i mean if i press "Y" the program will go to next day of loop and i can not enter time in and time out but if I press "N" the program will continue entering time in and time out...
Thanks in Advance masters...
- 06-02-2010, 03:16 PM #8
Senior Member
- Join Date
- Feb 2009
- Posts
- 303
- Rep Power
- 5
Sounds like you should figure out what phHein did and just reverse it.
- 06-02-2010, 05:08 PM #9
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Similar Threads
-
How can I rewrite the following while loop using a for loop?
By gt11990 in forum New To JavaReplies: 5Last Post: 04-30-2010, 05:05 PM -
Question about for loop..
By sivakumar_sakam in forum New To JavaReplies: 4Last Post: 05-15-2009, 11:23 PM -
How to loop a question when answer is negatve?
By brazuca in forum New To JavaReplies: 6Last Post: 04-23-2009, 05:46 AM -
nested for loop question
By javabob in forum New To JavaReplies: 3Last Post: 05-20-2008, 11:00 PM -
Question regarding foreach loop...
By theonlywalks in forum New To JavaReplies: 2Last Post: 03-15-2008, 06:15 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks