Advertisement
StefanTobler

Assignment 3

Oct 1st, 2016
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.15 KB | None | 0 0
  1.  import java.io.*;
  2.  import static java.lang.System.*;
  3.  import java.util.Random;
  4.  import java.util.Scanner;
  5.  import java.lang.Math;
  6.  
  7.  class Main{
  8.  
  9.  
  10.       public static void main (String str[]) throws IOException {
  11.          Scanner scan = new Scanner(System.in);
  12.          String[] months = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
  13.          int month;
  14.          int day;
  15.          String[] days = {"first", "second", "third", "fourth", "fifth", "sixth", "seventh", "eighth", "ninth", "tenth", "eleventh", "twelfth", "thirteenth", "fourteenth", "fifteenth", "sixteenth", "seventeenth", "eighteenth", "ninteenth", "twentieth", "twenty-first", "twenty-second", "twenty-third", "twenty-fourth", "twenty-fifth", "twenty-sixth", "twenty-seventh", "twenty-eighth", "twenty-ninth", "thirtieth", "thirty-first"};
  16.          System.out.println("On what day of the month were your born? (number)");
  17.          day = scan.nextInt();
  18.          System.out.println("In which month were you born? (number)");
  19.          month = scan.nextInt();
  20.          
  21.          if (day > 31 || day <= 0)
  22.          {
  23.           System.out.println("error");
  24.          }
  25.          
  26.          else if (month >12 || month <= 0)
  27.          {
  28.           System.out.println("error");
  29.          }
  30.          
  31.          else if ((month == 3 && day >= 21) || (month == 4 && day <= 19))
  32.          {
  33.           System.out.println("Your sign is Aries");
  34.           System.out.println("Your birthday is: " + months[month-1] + " " + days[day-1]);
  35.           System.out.println("Horoscope: Your fantastic!");
  36.          }
  37.              
  38.          else if ((month == 4 && day >= 20) || (month == 5 && day <= 20))
  39.          {
  40.           System.out.println("Your sign is Taurus");
  41.           System.out.println("Your birthday is: " + months[month-1] + " " + days[day-1]);
  42.           System.out.println("Horoscope: Your fantastic!");
  43.          }
  44.                  
  45.          else if ((month == 5 && day >= 21) || (month == 6 && day <= 20))
  46.          {
  47.           System.out.println("Your sign is Gemini");
  48.           System.out.println("Your birthday is: " + months[month-1] + " " + days[day-1]);
  49.           System.out.println("Horoscope: Your fantastic!");
  50.          }
  51.                  
  52.          else if ((month == 6 && day >= 21) || (month == 7 && day <= 22))
  53.          {
  54.           System.out.println("Your sign is Cancer");
  55.           System.out.println("Your birthday is: " + months[month-1] + " " + days[day-1]);
  56.           System.out.println("Horoscope: Your fantastic!");
  57.          }
  58.                  
  59.          else if ((month == 7 && day >= 23) || (month == 8 && day <= 22))
  60.          {
  61.           System.out.println("Your sign is Leo");
  62.           System.out.println("Your birthday is: " + months[month-1] + " " + days[day-1]);
  63.           System.out.println("Horoscope: Your fantastic!");
  64.          }
  65.                  
  66.          else if ((month == 8 && day >= 23) || (month == 9 && day <= 22))
  67.          {
  68.           System.out.println("Your sign is Virgo");
  69.           System.out.println("Your birthday is: " + months[month-1] + " " + days[day-1]);
  70.           System.out.println("Horoscope: Your fantastic!");
  71.          }
  72.                  
  73.          else if ((month == 9 && day >= 23) || (month == 10 && day <= 22))
  74.          {
  75.           System.out.println("Your sign is Libra");
  76.           System.out.println("Your birthday is: " + months[month-1] + " " + days[day-1]);
  77.           System.out.println("Horoscope: Your fantastic!");
  78.          }
  79.                  
  80.          else if ((month == 10 && day >= 23) || (month == 11 && day <= 21))
  81.          {
  82.           System.out.println("Your sign is Scorpio");
  83.           System.out.println("Your birthday is: " + months[month-1] + " " + days[day-1]);
  84.           System.out.println("Horoscope: Your fantastic!");
  85.          }
  86.                  
  87.          else if ((month == 11 && day >= 22) || (month == 12 && day <= 21))
  88.          {
  89.           System.out.println("Your sign is Sagittarius");
  90.           System.out.println("Your birthday is: " + months[month-1] + " " + days[day-1]);
  91.           System.out.println("Horoscope: Your fantastic!");
  92.          }
  93.                  
  94.          else if ((month == 12 && day >= 22) || (month == 1 && day <= 19))
  95.          {
  96.           System.out.println("Your sign is Capricorn");
  97.           System.out.println("Your birthday is: " + months[month-1] + " " + days[day-1]);
  98.           System.out.println("Horoscope: Your fantastic!");
  99.          }
  100.                  
  101.          else if ((month == 1 && day >= 20) || (month == 2 && day <= 18))
  102.          {
  103.           System.out.println("Your sign is Aquarius");
  104.           System.out.println("Your birthday is: " + months[month-1] + " " + days[day-1]);
  105.           System.out.println("Horoscope: Your fantastic!");
  106.          }
  107.                  
  108.          else if ((month == 2 && day >= 19) || (month == 3 && day <= 20))
  109.          {
  110.           System.out.println("Your sign is Pisces");
  111.           System.out.println("Your birthday is: " + months[month-1] + " " + days[day-1]);
  112.           System.out.println("Horoscope: Your fantastic!");
  113.          }                  
  114.       }
  115.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement