<file_sep>package com.techpro.javapractice;

//Program to print numbers from 1 to 10 in a single row with one tab space

public class NumbersInSingleRow {
    public static void main(String args[]){
        for(int i=1; i<=10; i++){
            System.out.print( i + "\t");
        }
    }
}
<file_sep>package com.techpro.javapractice;

// Program to print month in words, based on input month in numbers ex: input:12 outpot: December

import java.awt.print.PrinterException;

public class MonthInWords {
    public static void main(String args[]) {
        try {
//        converting input/Month(String) to integer
            int monthNum = Integer.parseInt(args[0]);
//        using switch statement Getting the Month in words
            switch (monthNum) {
//            if the Month number is 1 prints January
                case 1:
                    System.out.println("January");
//            if true exits from the loop
                    break;
//            if the Month number is 2 prints February
                case 2:
                    System.out.println("February");
                    break;
//            if the Month number is 3 prints March
                case 3:
                    System.out.println("March");
                    break;
//            if the Month number is 4 prints April
                case 4:
                    System.out.println("April");
                    break;
//            if the Month number is 5 prints May
                case 5:
                    System.out.println("May");
                    break;
//            if the Month number is 6 prints June
                case 6:
                    System.out.println("June");
                    break;
//            if the Month number is 7 prints July
                case 7:
                    System.out.println("July");
                    break;
//            if the Month number is 8 prints August
                case 8:
                    System.out.println("August");
                    break;
//            if the Month number is 9 prints September
                case 9:
                    System.out.println("September");
                    break;
//            if the Month number is 10 prints October
                case 10:
                    System.out.println("October");
                    break;
//            if the Month number is 11 prints November
                case 11:
                    System.out.println("November");
                    break;
//            if the Month number is 12 prints December
                case 12:
                    System.out.println("December");
                    break;
//            If the input is not between 1-12 prints invalid input
                default:
                    throw new PrinterException("Invalid Month");
            }
        }catch (PrinterException printerException) {
            System.out.println(printerException);
        }
    }
}
<file_sep>package com.techpro.javapractice;

/*an application for employee management having following classes: a)
Create an Employee class with following attributes and behaviors : i) EmpId Int ii)
EmpName String iii) EmpEmail String iv) EmpGender char v) EmpSalary float vi)
GetEmployeeDetails() -> prints employee details
*/

public class Employee {
//Declaration of Employee variable to store employee details
    private int empId;
    private String empName;
    private String empEmail;
    private char empGender;
    private float empSalary;

//    Employee constructor
    public Employee() {
    }

//    Employee Constructor with parameters
    public Employee(int empId,String empName,String empEmail,char empGender,float empSalary) {
        this.empId = empId;
        this.empName = empName;
        this.empEmail = empEmail;
        this.empGender = empGender;
        this.empSalary = empSalary;

    }

//    Getter and setter methods to access the employee details

    public int getEmpId() {
        return empId;
    }

    public void setEmpId(int empId) {
        this.empId = empId;
    }

    public String getEmpName() {
        return empName;
    }

    public void setEmpName(String empName) {
        this.empName = empName;
    }

    public String getEmpEmail() {
        return empEmail;
    }

    public void setEmpEmail(String empEmail) {

        this.empEmail = empEmail;
    }

    public char getEmpGender() {

        return empGender;
    }

    public void setEmpGender(char empGender) {

        this.empGender = empGender;
    }

    public float getEmpSalary() {

        return empSalary;
    }

    public void setEmpSalary(float empSalary) {

        this.empSalary = empSalary;
    }

//    Method to get employee details
    public String getEmployeeDetails() {
        return "Employee ID:" + empId + "EmployeeName:" + empName + "EmployeeEmail:" + empEmail +
                "EmployeeGender:" + empGender + "EmployeeSalary:" + empSalary;
    }

//    toString Method to return employee object
    public String toString() {
        return "Employee ID:" + empId + ", EmployeeName:" + empName + ", EmployeeEmail:" + empEmail +
                ", EmployeeGender:" + empGender + ", EmployeeSalary:" + empSalary;
    }
}
<file_sep>package com.techpro.javapractice;

// Program to print prime numbers between 10 and 99.

public class PrimeNumbersBetweenRange {
    public static void main (String args[]) {
//        loop to get prime numbers between 10-99
        System.out.println("Prime Numbers between 10 to 99:");
        for (int i = 10; i <= 99; i++) {
//            Setting boolean variable to false to check prime
            boolean flag = false;
//            for each number between 10-99 checks the prime number condition
            for (int j = 2; j <= i/2; j++) {
                if (i % j == 0) {
//                    if it is not prime set flag to true
                    flag = true;
                    break;
                }
            }
//            if the variable/number in i prime then prints the number
            if (!flag){
                System.out.println(i);
            }
        }
    }
}
<file_sep>package com.techpro.javapractice;
// program to check if the program has received command line arguments or not
public class CommandLineArguments {
    public static void main(String args[]) {
//        Storing length of input in a variable (n)
        int n = args.length;
//        if the input contain data then prints the input by comma separator
        if(n > 0) {
//            if true print the arguments/input  one by one with comma separator until last but one
            for (int i=0;i< n-1;i++) {
                System.out.print(args[i] + ",");
            }
//            printing last index data
          System.out.print(args[n-1]);
        }else
//            if there is no input then prints No Values message
            System.out.println("No Values");
    }
}
<file_sep>package com.techpro.javapractice;

//program to check if a given number is Positive, Negative, or Zero.

import java.util.Scanner;


public class NumberCheck {
    public static void main(String args[]){
//        Taking input from user
            System.out.println("Please enter the number to check Positive/Negative/Zero ");
            Scanner in = new Scanner(System.in);
//        Storing input in variable n
            int n = in.nextInt();
//        passing variable n to numberChecker Method to check the number
            numberChecker(n);
        }

//numberChecker method to check the given number (n) is positive/Negative/Zero
    public static void numberChecker(int n) {

/* if the given number is equal to zero prints zero,
if the number is less than zero then prints as Negative
if the number is greater than zero prints as positive number */

        if (n == 0) {
            System.out.println("The Given number is Zero");
        } else if (n < 0) {
            System.out.println("The given number is Negative ");
        } else if (n > 0) {
            System.out.println("The given number is Positive");
        } else
            System.out.println("The given number is invalid ");
    }

}
<file_sep>package com.techpro.javapractice;

/* Program to Create one more class EmployeeDB which has the following methods. i) boolean
addEmployee(Employee e) ii) boolean deleteEmployee(int empId) iii) String
showPaySlip(int empId) iv) Employee[] listAll()*/

import java.util.*;

public class EmployeeDB {
//    Creating database variable of employee type of List to store
    List<Employee> db = new ArrayList<>();

//    Method to add a employee of Employee class type into Arraylist
    public boolean addEmployee(Employee e) {
        return db.add(e);
    }

//    Method to delete employee from ArrayList
    public boolean deleteEmployee(int empId){
        boolean flag = false;
//        Iterartor to run through db arraylist
        Iterator<Employee> iterator = db.iterator();
        while (iterator.hasNext()){
//           Employee class type instance
            Employee employee = iterator.next();
            if (employee.getEmpId() == empId) {
                flag = true;
                iterator.remove();
            }
        }return flag;
    }

//    Method to get the salary of  empId
    public String showPaySlip(int empId) {
//        Defining the String type variable to return
        String paySlip = "Not a valid empId";
//        Iterartor to go through arraylist data
        Iterator<Employee> iterator = db.iterator();
        while (iterator.hasNext()) {
            Employee employee = iterator.next();
            if (employee.getEmpId() == empId) {
                float salary = employee.getEmpSalary();
                paySlip = String.valueOf(salary);
            }
        }
        return paySlip;
    }

//    Method to return array of employees from listarray
    public Employee[] listAll() {
        Employee[] listallEmpArray = db.toArray(new Employee[0]);
        return listallEmpArray;
    }


}
<file_sep>package com.techpro.javapractice;

// Program to check if a given number is prime or not

public class PrimeNumberChecker {
    public static void main (String args[]) {
        try {
//        converting input to a integer variable
            int numberToCheckPrime = Integer.parseInt(args[0]);

//        Initializing boolean variable to false
            boolean flag = false;

//        If the given number is zero or one

            if (numberToCheckPrime == 0 || numberToCheckPrime == 1) {
                System.out.println(numberToCheckPrime + " is neither prime nor composite");
                return;
            }


//        loop to check prime number
            for (int i = 2; i <= numberToCheckPrime / 2; i++) {
//            If the remainder is zero then it is a non prime number
                if (numberToCheckPrime % i == 0) {
//               Number is not prime so Setting flag to true
                    flag = true;
//                Even enter oncce, it is not a prime ,using break coming out of loop
                    break;
                }
            }
//        if the flag does not change then it is a prime number
            if (flag == false) {
                System.out.println(numberToCheckPrime + " is Prime Number");
            }
//        if flag override then it is not a prime
            else
                System.out.println(numberToCheckPrime + "The given Number is not a Prime");
        }catch (NumberFormatException numberFormatException) {
            System.out.println(numberFormatException);
        }

    }
}
<file_sep>package com.techpro.javapractice;
/*Program to print the color name, based on color code. If color code is not valid
*then print "Invalid Code". R->Red, B->Blue, G->Green, O->Orange, Y->Yellow,
*W->White*/
public class ColorCode {
    public static void main (String args[]) {
//        Initializing COlor code
        char colorCode = 'z';
//        Switch Statement to get Color for given colorcode
        switch (colorCode) {
            case 'R':
                System.out.println("R -> Red");
                break;
            case 'B':
                System.out.println("B -> Blue");
                break;
            case 'G':
                System.out.println("G -> Green");
                break;
            case 'O':
                System.out.println("O -> Orange");
                break;
            case 'Y':
                System.out.println("Y -> Yellow");
                break;
            case 'W':
                System.out.println("W -> White");
                break;
//                If the colorcode is not valid prints the default message
            default:
                System.out.println("Invalid Code");
        }
    }
}
<file_sep>package com.techpro.javapractice;

// Program to print first 5 values which are divisible by 2, 3, and 5

public class FiveValuesDivisibleBy {
    public static void main(String args[]) {
//        initializing counter variable to limit the number of value to be printed
        int counter = 0;
        System.out.println("Values Divisable by 2,3, and 5:");
//        loop to get values
            for (int i = 2; i <= 300; i++) {
//                condition if the int i is divisible by 2,3, and 5 then enter in to the loop
                if (i % 2 == 0 && i % 3 == 0 && i % 5 == 0) {
//                    if divisible then increasing the counter value
                    counter++;
//                    printing divisible value
                    System.out.println(i);
                }
//                return if 5 values printed
                while (counter >= 5){
                    return;
            }
        }
    }
}
<file_sep>package com.techpro.javapractice;

// Program on ArrayList which will be able to store only numbers like int,float,double,etc.

import java.util.ArrayList;
import java.util.List;

public class ArrayListToStoreDiffdatatypes {
    public static void main(String[] args) {
//        creating ArrayList
        List<Object> al = new ArrayList<Object>();
//        adding data to arraylist
        al.add(123);
        al.add(11);
        al.add(78.48900F);
        al.add(3.32938F);
        al.add(123.1235678D);
        al.add("String");
//        Printing arraylist
        System.out.println(al);
    }
}
<file_sep>package com.techpro.javapractice;
/*Program to accept gender ("Male" or "Female") and age (1-120) from command
line arguments and print the percentage of interest based on the given conditions.
Interest == 8.2% Gender ==> Female Age ==>1 to 58 Interest == 7.6% Gender ==>
Female Age ==>59 -120 Interest == 9.2% Gender ==> Male Age ==>1-60 Interest ==
8.3% Gender ==> Male Age ==>61-120
*/
public class InterestRate {
    public static void main (String args[]) {
        try {
//        Converting second String argument(age) to int
        int stringTointAge = Integer.parseInt(args[1]);
//        check if the condition is female and age between 1-58 prints the Message
            if ((args[0].equals("Female")) && (stringTointAge <= 58 && stringTointAge >= 1)) {
                System.out.println("Interest == 8.2% ");
            }
//        check if the condition is female and age between 59-120 prints the Message
            else if ((args[0].equals("Female")) && (stringTointAge <= 120 && stringTointAge >= 59)) {
                System.out.println("Interest == 7.6% ");
            }
//        check if the condition is male and age between 1-60 prints the Message
            else if ((args[0].equals("Male")) && (stringTointAge <= 60 && stringTointAge >= 1)) {
                System.out.println("Interest == 9.2% ");
            }
//        check if the condition is male and age between 61-120 prints the Message
            else if ((args[0].equals("Male")) && (stringTointAge <= 120 && stringTointAge >= 61)) {
                System.out.println("Interest == 8.3%");
            } else {
                System.out.println("Invalid Input");
            }
        }catch (Exception e) {
            System.out.println(e);
        }
    }
}
