Skip to content

Instantly share code, notes, and snippets.

@raphaelsaunier
Created October 20, 2010 11:03
Show Gist options
  • Save raphaelsaunier/636198 to your computer and use it in GitHub Desktop.
Save raphaelsaunier/636198 to your computer and use it in GitHub Desktop.
import java.util.Scanner;
public class VaccineTest
{
public static void main (String[] args) {
while(true){
Scanner scan = new Scanner(System.in);
int age;
char inFlu;
char pregnant;
System.out.print("\n\tEnter your age: ");
age = scan.nextInt();
System.out.print("\n\tDo you belong to a seasonal flu at-risk group? (y/n): ");
inFlu = scan.next().charAt(0);
System.out.print("\n\tAre you pregnant? (y/n): ");
pregnant = scan.next().charAt(0);
if ((pregnant == 'y' || pregnant == 'n') && (inFlu == 'y' || inFlu == 'n')){
if (age<65 && inFlu == 'y')
System.out.println ("Please visit your doctor between October 26th and November 6th. ");
else if (pregnant == 'y')
System.out.println ("Please visit your doctor between November 9th and November 20th. ");
else
System.out.println ("You do not need to be vaccinated. ");
}
else
System.out.println ("Input Error. Please start again. ");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment