Ok I got it working with:
import java.util.Scanner;
public class BirthdayEdit {
public static void main (String arg[])
{
Scanner sc = new Scanner(System.in);
boolean cont =...
Type: Posts; User: Tjstretch
Ok I got it working with:
import java.util.Scanner;
public class BirthdayEdit {
public static void main (String arg[])
{
Scanner sc = new Scanner(System.in);
boolean cont =...
Hmm thats interesting, one second
I edited the code that I posted, look at how I did it.
Yes, it would do that with the above code, except it would ask
"Continue?"
after all that. Run the code and see for yourself
As for checking if its not Febuary 30th, add this with all your other validity checks
else if(birthMonth == 2 && birthDay == 30)
{
System.out.println("Invalid day!");
break;
}
Ok, 2 things. You should change
int birthMonth = sc.nextInt();
int birthDay = sc.nextInt();
int birthYear = (sc.nextInt() - 1900);
to
System.out.println("What is your birth month?");...
Sorry if I'm getting over your head, I can break all the code down and explain it if you want ;)
Also, it will make your code look a little less to-the-point, because you have to check everything...
Oh, thats what you meant. Just use a while statement and an if statement, like so:
int birthMonth = sc.nextInt();
while(birthMonth > 12 || birthMonth < 0)
{
System.out.println("Invalid birth...
You're Welcome, as to your request:
Throwing an error:
throw new AssertionError("Maximum 29 days in Febuary");
Reviewed your code, you should use a switch statement, then use one println. ...
Thats a very basic mistake, happens to everyone. Change
int birthMonthAdd;
to
int birthMonthAdd = 0;
It has to do with the compiler not knowing that it will actually get initialized in...