Skip to content

Ranjitha-tech/Java-selection-statement

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

30 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

My First Java Project

Description

This is a simple Java program that prints "Hello GitHUb!".

How to Run

  1. Compile the program: javac hello.java

  2. Run the program: java hello

Technologies Used

  • Java

๐Ÿงช Day 1: Java Datatypes Practice

๐Ÿ“Œ Program: Mydetails.java

This program demonstrates the use of different Java datatypes by storing and printing personal details.

๐Ÿ”ข Datatypes Used

  • String โ†’ Name
  • int โ†’ Age
  • byte โ†’ Number of siblings
  • long โ†’ Phone number
  • float โ†’ Height
  • double โ†’ Weight
  • boolean โ†’ Student status

๐ŸŽฏ Output

The program prints formatted personal information using different datatypes.

๐Ÿ’ก Key Learning

  • Understood primitive and non-primitive datatypes
  • Learned how to store and display values
  • Practiced basic Java syntax and structure

๐Ÿงฎ Java Operators Program

๐Ÿ“Œ Overview

This project is a simple Java program that demonstrates the use of basic arithmetic operators. It performs operations on two integer variables and prints the results.

๐Ÿ’ป Language Used Java

๐Ÿ“‚ Program Description The program:

Declares two integer variables a and b Performs different arithmetic operations Prints the results to the console ๐Ÿ”ข Operators Used Addition (+) Subtraction (-) Multiplication (*) Division (/) Modulus (%)

โ–ถ๏ธ How to Run Make sure Java is installed

Save the file as:

operators.java

Open terminal and compile:

javac operators.java

Run the program:

java operators ๐Ÿ“Œ Output sum: 30 8 80 0 10 ๐ŸŽฏ Learning Objective Understand how arithmetic operators work in Java Learn integer division and modulus behavior Practice writing and running basic Java programs ๐Ÿ‘ค Author

Ranjitha N

Voting Eligibility Checker

This is a simple Java program that checks whether a person is eligible to vote using basic if conditions.

๐Ÿ“Œ Description

The program takes a person's age as input and determines if they are allowed to vote or not. If the age is 18 or above, the person is eligible to vote. Otherwise, they are not eligible.

โš™๏ธ Features

  • Uses simple if condition
  • Easy to understand logic
  • Beginner-friendly program

๐Ÿ› ๏ธ Technologies Used

  • Java

โ–ถ๏ธ How It Works

  1. Enter age

  2. Program checks condition:

    • If age โ‰ฅ 18 โ†’ Eligible to vote
    • Else โ†’ Not eligible

๐Ÿ‘ฉโ€๐Ÿ’ป Author

Ranjitha N

Voting Eligibility Checker ๐Ÿ—ณ๏ธ

๐Ÿ“Œ Description

This is a simple Java program that checks whether a person is eligible to vote based on their age using conditional statements.

๐Ÿš€ Features

  • Uses basic if-else condition
  • Beginner-friendly Java program
  • Demonstrates decision-making logic

๐Ÿง  Logic

  • If age is greater than or equal to 18 โ†’ Eligible to vote
  • Otherwise โ†’ Not eligible to vote

๐Ÿ’ป Code Example

class Result {
    public static void main(String[] args) {
        int age = 20;

        if (age >= 18) {
            System.out.println("The person is eligible to vote");
        } else {
            System.out.println("The person is not eligible to vote");
        }
    }
}

โ–ถ๏ธ How to Run

  1. Save the file as Result.java

  2. Open terminal in the file location

  3. Compile the program:

    javac Result.java
    
  4. Run the program:

    java result
    

๐Ÿ“Š Example Output

The person is eligible to vote

๐Ÿ› ๏ธ Technologies Used

  • Java

๐ŸŽฏ Purpose

This project is created as part of learning Java fundamentals and improving programming logic for coding interviews.


Income Eligibility Checker (Java)

This is a simple Java program that checks whether a student is eligible for a scholarship based on their income.

๐Ÿ“Œ Description

The program takes a fixed income value and uses an if-else condition to determine eligibility.

  • If income is greater than 7000 โ†’ Scholarship Available
  • Otherwise โ†’ Not eligible for scholarship

๐Ÿ’ป Technologies Used

  • Java
  • Basic If-Else Statement

โ–ถ๏ธ How to Run

  1. Compile the program: javac Income.java

  2. Run the program: java Income

๐Ÿ“‚ Sample Output

Not eligible for scholarship

๐ŸŽฏ Purpose

This program is useful for beginners to understand:

  • Conditional statements in Java
  • Basic program structure

Divisibility Checker (Java)

This is a simple Java program that checks whether a number is divisible by both 3 and 5 using nested if statements.

๐Ÿ“Œ Description

The program initializes a number and checks:

  • If the number is divisible by 3
  • Then it checks if the number is also divisible by 5

If both conditions are satisfied, it prints that the number is divisible by both 3 and 5.

๐Ÿ’ป Technologies Used

  • Java
  • Nested If-Else Statements

โ–ถ๏ธ How to Run

  1. Compile the program: javac Divisible.java

  2. Run the program: java Divisible

๐Ÿ“‚ Sample Output

Number is divisible by both 3 and 5

โš ๏ธ Note

The current program only prints output when the number is divisible by both 3 and 5. If the number is divisible by 3 but not by 5, no output will be shown.

๐ŸŽฏ Purpose

This program helps beginners understand:

  • Nested if conditions
  • Modulus operator (%)
  • Logical checking in Java

About

"Basic Java Program"

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages