|
-
How do you loop a switch statement?
I am creating a program that will allow a person to input a month, day and year and this program will convert it to the day of the year. However, I want it to loop until the person puts in a -1. How do i get it to loop?
public void findCalen(){
String prompt = "Enter a month or -1 to stop";
int num1=readInt(prompt);
if (num1!=-1){
String dayStr=JOptionPane.showInputDialog(null,"Enter a day");
int dayA=Integer.parseInt(dayStr);
String yearStr=JOptionPane.showInputDialog(null,"Enter a year");
int yearA=Integer.parseInt(yearStr);
int (yearA % 100 == 0 || yearA % 4 == 0) {
switch (num1){
case 1:numOfDays=dayA;
System.out.println(numOfDays);
break;
.
.
.
case 12:numOfDays = 335+dayA;
System.out.println(numOfDays);}
}
else
switch (num1){
case 1:numOfDays = dayA;
System.out.println(numOfDays);
break;
.
.
.
case 12:numOfDays = 334+dayA;
System.out.println(numOfDays);}
}
else{
System.out.println("good bye"); }
}
Similar Threads
-
By Laurel in forum VB Classic
Replies: 4
Last Post: 10-28-2005, 02:15 PM
-
By salvinger in forum VB Classic
Replies: 0
Last Post: 05-07-2005, 01:38 PM
-
By Daryl Shockey in forum Database
Replies: 2
Last Post: 05-28-2002, 03:50 PM
-
By James Lin in forum .NET
Replies: 9
Last Post: 08-15-2000, 10:54 AM
-
Replies: 1
Last Post: 05-02-2000, 03:29 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks