Java Tutorial : How To Create Zodiac Checker Program On NetBeans

in utopian-io •  6 years ago  (edited)

Repository

https://github.com/dmlloyd/openjdk

What Will I Learn?

  • You will learn how to create program to check zodiac
  • You will learn how to create simple application
  • You will learn how to implement if-else for zodiac checker

Requirements

  • you must understand basic of JAVA programming
  • you must know how to implement if conditional on java
  • NetBeans

Difficulty

Choose one of the following options:

  • Basic

Tutorial Contents

okay, on this occasion I will share tutorial to create an application to determine your zodiac based on date and month of birth, in this program I will create two variables, month variable and date variable, and we will make if conditioning to be able to display zodiac which match the date and month of birth that have been entered, I will use the scanner input method for this program.

  • okay, just go to the tutorial:
  • first you must create a new class on NetBeans:
  • the name you should create for your new class is Zodiak.java
  • then type the program below, I will explain later.
import java.util.Scanner;
public class Zodiak{
    public static void main(String[] args) {

        int date, month;
        Scanner sc = new Scanner(System.in);
        System.out.println("input your date : ");
        date = sc.nextInt();

        System.out.println("input your mounth: ");
        month = sc.nextInt();

        if ((date>21 && month == 12) || (date<=19 && month== 1)){
           System.out.println("your zodiac is Capricon");
       }
       if ((date>20 && month ==1) || (date<=18 && month == 2)){
           System.out.println("your zodiac is Aquarius");
       }
       if ((date>19 && month == 2) || (date <=20 && month == 3)){
           System.out.println("your zodiac is Pisces");
       }
       if ((date>21 && month == 3) || (date <=20 && month == 4)){
           System.out.println("your zodiac is aries");
       }
       if ((date>21 && month == 4) || (date <=20 && month == 5)){
           System.out.println("your zodiac is Taurus");
       }
       if ((date>21 && month == 5) || (date<=20 && month == 6)){
           System.out.println("your zodiac is Gemini");
       }
       if ((date>21 && month == 6) || (date<=20 && month == 7)){
           System.out.println("your zodiac is Cancer");
       }
       if ((date>21 && month  == 7) || (date<=20 && month== 8)){
           System.out.println("your zodiac is  Leo");
       }
       if ((date>21 && month ==8) || (date<=22 && month == 9)){
           System.out.println("your zodiac is Virgo");
       }
       if ((date>23 && month == 9) || (date<=20 && month ==10)){
           System.out.println("your zodiac is Libra");
       }
       if ((date>21 && month == 10) || (date<=22 && month == 11)){
           System.out.println("your zodiac is Scorpio");
       }
       if ((date>23 && month == 11) || (date<=20 && month == 12)){
           System.out.println("your zodiac is Sagitarius");
       }
    }
}
  • this class import java.util.Scanner; we use because we use scanner input method.
  • public class Zodiac { This is the declaration of the name of the class that you have loaded before, you must equate with the name you have created earlier.
  • Scanner sc = new Scanner (System.in); This is the declaration of a new scanner object.
  • this is for the process of inputting birth date:
System.out.println("input your date : ");
        date = sc.nextInt();
  • and this is for the declaration of the month of birth:
System.out.println("input your month: ");
        mounth = sc.nextInt();
  • okay, then we will make conditioning to mengontiskan zodiac in accordance with the date of birth that has been entered.

  • first we will make conditioning to display the capricon zodiac:
if ((date>21 && month == 12) || (date<=19 && month== 1)){
           System.out.println("your zodiac is Capricon");

above is the condition that we make that if the birth date is more than 21 and the birth month is 12 it will print the output of your Zodiac is Capricon.


  • then we will create conditions to display the aquarius zodiac
if ((date>20 && month ==1) || (date<=18 && month == 2)){
           System.out.println("your zodiac is Aquarius");

the condition is if the birth date is more than 20 and the month of birth is 1, and if the date of birth is less than or equal to 18 and the month of birth is 2 then it will print your zodiac is aquarius.


  • then we will create conditions to display the pisces zodiac
 if ((date>19 && month == 2) || (date <=20 && month == 3)){
           System.out.println("your zodiac is Pisces");

the condition of the above program part means if the birth date is more than 19 and the month of birth is 2, and if the date of birth is smaller or sam with 20 and month of birth is 3 then it will show zodiac pisces.


actually the formulas for all zodiacs are just different only on date conditioning only.

  • for the next one just the same, you just need to change in the number only
  • You can continue by looking at the numbers in the picture below:

  • okay, if the program is finished you create, then we will run the program:

  • after running it will look like this, input your date and month of birth:

  • above we have created the date of birth: 5 March, then we see if the program is already running in accordance with the formula we have entered before, we will see in the program that displays the zodiac pisces to prove it.


    okay, the program is running according to the conditions we have entered

OKAY TUTORIAL IS COMPLETE, SORRY IF THERE IS A MISTAKE

Curriculum

Include a list of related tutorials you have already shared on Utopian that make up a Course Curriculum, if applicable.

Proof of Work Done

https://gist.github.com/andilapulga/cf75412f73253a4f1706c6632881a997

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

High quality post @lapulga

Thank you for your contribution.
Your contribution will not be rewarded for the following reasons:

  • Your code is very similar to this link.

Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]