assignment java

import java.util.Scanner;

//Some websites impose certain rules for passwords,
//Write a java program that checks whether a string is valid passwords,
//suppose the password rule is as follows,
//A password must have at least eight characters,
//A password consists of only letters and digits, 
//A password must contain at least two digits,
//your program prompts the user to enter a password and displays"valid password",
//if the rule is followed or"invalid password otherwise",

public class Ok {
    public static void main(String[] args) {
        Scanner input=new Scanner(System.in);
        System.out.println("Enter the password:");
        String password=input.next();
        if(isLeastEightChara(password)&&isContainLeastTwoDigits(password)&&isOnlyLettersandDigits(password))
        {
            System.out.println("Valid password");
        }
        else
        {
            System.out.println("inValid password");

        }

        

    }
    public static boolean isLeastEightChara(String password)
    {
        if(password.length()<=8)
        {
            return true;
        }
        else
        {
            return false;
        }
    };
    public static boolean isContainLeastTwoDigits(String password)
    {
        int count=0;
        for(int i=0;i<password.length();i++)
        {
        char pass=password.charAt(i);
        if(Character.isDigit(pass))
        {
            count++;
        }
        }
        if(count>=2)
        {
            return true;
        }
        else
        {
            return false;
        }
    };
    public static boolean isOnlyLettersandDigits(String password){
        boolean a=false;
        for(int i=0;i<password.length();i++){
        char pass=password.charAt(i);
        if(Character.isDigit(pass)&&Character.isAlphabetic(pass)){
            a=true;
        }
        return a;
    }
    
}
    
}
//Some websites impose certain rules for passwords,
//Write a java program that checks whether a string is valid passwords,
//suppose the password rule is as follows,
//A password must have at least eight characters,
//A password consists of only letters and digits, 
//A password must contain at least two digits,
//your program prompts the user to enter a password and displays"valid password",
//if the rule is followed or"invalid password otherwise",

public class Ok {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.println("Enter the password:");
        String password = input.next();
        System.out.println(password.length());
        if (isLeastEightChara(password) && isContainLeastTwoDigits(password) && isOnlyLettersandDigits(password)) {
            System.out.println("Valid password");
        } else {
            System.out.println("inValid password");
        }
        System.out.println(isLeastEightChara(password));
        System.out.println(isContainLeastTwoDigits(password));
        System.out.println(isOnlyLettersandDigits(password));

    }
    public static boolean isLeastEightChara(String password) {
        if (password.length() >= 8) {
            return true;
        } else {
            return false;
        }
    };

    public static boolean isContainLeastTwoDigits(String password) {
        int count = 0;
        for (int i = 0; i < password.length(); i++) {
            char pass = password.charAt(i);
            if (Character.isDigit(pass)) {
                count++;
            }
        }
        if (count >= 2) {
            return true;
        } else {
            return false;
        }
    };
    public static boolean isOnlyLettersandDigits(String password) {
        boolean ahmed = false;
        for (int i = 0; i < password.length(); i++) {
            char pass = password.charAt(i);
            if (Character.isDigit(pass)) {
                ahmed = true;
            } else if (Character.isAlphabetic(pass)) {
                ahmed = true;
            } else {
                ahmed = false;
            }
        }
        return ahmed;
    };

}
import java.util.Scanner;

//Some websites impose certain rules for passwords,
//Write a java program that checks whether a string is valid passwords,
//suppose the password rule is as follows,
//A password must have at least eight characters,
//A password consists of only letters and digits, 
//A password must contain at least two digits,
//your program prompts the user to enter a password and displays"valid password",
//if the rule is followed or"invalid password otherwise",

public class Ok {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.println("Enter the password:");
        String password = input.next();
        System.out.println(password.length());
        if (isLeastEightChara(password) && isContainLeastTwoDigits(password) && isOnlyLettersandDigits(password)) {
            System.out.println("Valid password");
        } else {
            System.out.println("inValid password");
        }
        System.out.println(isLeastEightChara(password));
        System.out.println(isContainLeastTwoDigits(password));
        System.out.println(isOnlyLettersandDigits(password));

    }

    public static boolean isLeastEightChara(String password) {
        if (password.length() >= 8) {
            return true;
        } else {
            return false;
        }
    };

    public static boolean isContainLeastTwoDigits(String password) {
        int count = 0;
        for (int i = 0; i < password.length(); i++) {
            char pass = password.charAt(i);
            if (Character.isDigit(pass)) {
                count++;
            }
        }
        if (count >= 2) {
            return true;
        } else {
            return false;
        }
    };

    public static boolean isOnlyLettersandDigits(String password) {
        boolean ahmed = false;
        for (int i = 0; i < password.length(); i++) {
            char pass = password.charAt(i);
            if (Character.isDigit(pass)) {
                ahmed = true;
            } else if (Character.isAlphabetic(pass)) {
                ahmed = true;
            } else {
                ahmed = false;
            }
        }
        return ahmed;
    };

}
public class Ok {
    public static void main(String[] args) {
        System.out.println("\n\n    1   2   3   4   5   6   7   8   9   10");// tab.
        System.out.println("----------------------------------------------");

        for (int i = 1; i <= 10; i++) {
            if (i < 10) {
                System.out.print(i + " |");
            } else {
                System.out.print(i + "|");
            }
            for (int j = 1; j <= 10; j++) {
                int z = i * j;
                if (z >= 10) {
                    System.out.print(z + "  ");
                } else {
                    System.out.print(z + "   ");
                }
            }
            System.out.println();
        }

    };

}
import java.util.Scanner;

//Write a program that reads an unspecified number of scores and,
//determines how many scores are above or equal to the average and how many,
//scores are below the average. Enter a negative number to signify the end of the,
//input. Assume that the maximum number of scores is (10),
public class Ok {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.print("Enter Scores:(negative number signifies end):");
        int scores[] = new int[10];
        int numberofScores = 0;
        int average = 0;
        for (int i = 0; i < 10; i++) {
            scores[i] = input.nextInt();
            if (scores[i] < 0)
                break;
            average += scores[i];
            numberofScores++;
        }
        average /= numberofScores;
        int AboveOREqual = 0, below = 0;
        for (int i = 0; i < numberofScores; i++) {
            if (scores[i] >= average) {
                AboveOREqual++;
            } else {
                below++;
            }
        }
        System.out.println("\n Average of scores:" + average);
        System.out.println("Number of scores above or equal to average:" + AboveOREqual);
        System.out.println("Number of scores below average:" + below);

    };
};
import java.util.Scanner;

//Write a program that reads an unspecified number of scores and,
//determines how many scores are above or equal to the average and how many,
//scores are below the average. Enter a negative number to signify the end of the,
//input. Assume that the maximum number of scores is (10),

public class Ok {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.print("Enter Scores:(negative number signifies end):");
        int scores[] = new int[10];
        int numberofScores = 0;
        int average = 0;
        for (int i = 0; i < 10; i++) {
            scores[i] = input.nextInt();
            if (scores[i] < 0)
                break;
            average += scores[i];
            numberofScores++;
        }
        average /= numberofScores;
        int AboveOREqual = 0, below = 0;
        for (int i = 0; i < numberofScores; i++) {
            if (scores[i] >= average) {
                AboveOREqual++;
            } else {
                below++;
            }
        }
        System.out.println("\n Average of scores:" + average);
        System.out.println("Number of scores above or equal to average:" + AboveOREqual);
        System.out.println("Number of scores below average:" + below);

    };
};
//import java.util.Scanner;

//write a program that computes weekly hours for each employee;
//Use a two-dimensional array.Each row records an employee's
//seven-day work hours with seven columns. 

public class Ok {
    public static int[] Sumhours(int[][] hours) {

        int TotalHoursForEachEmployee[] = new int[hours.length];
        for (int i = 0; i < hours.length; i++) {
            int sum = 0;
            for (int j = 0; j < hours[i].length; j++) {
                sum += hours[i][j];
            }
            TotalHoursForEachEmployee[i] = sum;
        }
        return TotalHoursForEachEmployee;

    }

    public static void main(String[] args) {
        // Scanner in = new Scanner(System.in);
        // int Employeeworkhours[][] = new int[7][7];
        int[][] Employeeworkhours = { 
        { 1, 2, 3, 4, 5, 6, 7 },
        { 8, 9, 10, 11, 12, 13, 14 },
        { 15, 16, 17, 18, 19, 20, 21 },
        { 22, 23, 24, 25, 26, 27, 28 },
        { 29, 30, 31, 32, 33, 34, 35 },
        { 36, 37, 38, 39, 40, 41, 42 },
        { 10, 20, 30, 40, 50, 60, 70 } };
        /*
         * for (int i = 0; i < Employeeworkhours.length; i++) { for (int j = 0; j <
         * Employeeworkhours[i].length; j++) { Employeeworkhours[i][j] = in.nextInt(); }
         * }
         */
        int total[] = Sumhours(Employeeworkhours);
        for (int i = 0; i < total.length; i++) {
            System.out.println(total[i]);
        }
    };
};
import java.util.Scanner;

//write a program that computes weekly hours for each employee;
//Use a two-dimensional array.Each row records an employee's
//seven-day work hours with seven columns. 

public class Ok {
    public static int[] Sumhours(int[][] hours) {

        int TotalHoursForEachEmployee[] = new int[hours.length];
        for (int i = 0; i < hours.length; i++) {
            int sum = 0;
            for (int j = 0; j < hours[i].length; j++) {
                sum += hours[i][j];
            }
            TotalHoursForEachEmployee[i] = sum;
        }
        return TotalHoursForEachEmployee;

    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int Employeeworkhours[][] = new int[7][7];
        System.out.println("Enter employee work hours:");

        for (int i = 0; i < Employeeworkhours.length; i++) {
            for (int j = 0; j < Employeeworkhours[i].length; j++) {
                Employeeworkhours[i][j] = in.nextInt();
            }
            ;
        }
        ;

        int total[] = Sumhours(Employeeworkhours);
        for (int i = 0; i < total.length; i++) {
            System.out.println("employee work hours:" + (i+1) + "=");
            System.out.println(total[i]);
        }
        ;
    };
};
import java.util.Scanner;

//write a program that computes weekly hours for each employee;
//Use a two-dimensional array.Each row records an employee's
//seven-day work hours with seven columns. 
public class Ok {
    public static int[] Sumhours(int[][] hours) {

        int TotalHoursForEachEmployee[] = new int[hours.length];
        for (int i = 0; i < hours.length; i++) {
            int sum = 0;
            for (int j = 0; j < hours[i].length; j++) {
                sum += hours[i][j];
            }
            TotalHoursForEachEmployee[i] = sum;
        }
        return TotalHoursForEachEmployee;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int Employeeworkhours[][] = new int[7][7];
        System.out.println("Enter employee work hours:");

        for (int i = 0; i < Employeeworkhours.length; i++) {
            for (int j = 0; j < Employeeworkhours[i].length; j++) {
                Employeeworkhours[i][j] = in.nextInt();
            }
        }
        int total[] = Sumhours(Employeeworkhours);
        for (int i = 0; i < total.length; i++) {
            System.out.println("employee work hours:" + (i + 1) + "=");
            System.out.println(total[i]);
        }
    }
}
import java.util.Scanner;

public class Ok {

    // a method to find the greatest common divisor.
    // of given tv numbers.
    public static int GCD(int num1, int num2) {
        int gcd = 0, x = 0;
        if (num1 > num2) {
            x = num1 / num2;
            gcd = num1 - (num2 * x);
        }
        if (num2 > num1) {
            x = num2 / num1;
            gcd = num2 - (num2 * x);
        }
        return gcd;

    }

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int num1, num2;
        System.out.println("Enter numer1:");
        num1 = input.nextInt();
        System.out.println("Enter number2:");
        num2 = input.nextInt();
        System.out.println("gcd=" + GCD(num1, num2));

    }

}
import java.util.Scanner;
public class Ok {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        float num = input.nextFloat();
        float sum = 0;
        for (float i = 0; i <= 28; i++) {
            sum = sum + num;
            num = num + 0.07f;
            System.out.printf("The num=:%f", num);
            System.out.println();
        }
        System.out.println("The sum of series:" + (int) sum);
    }
}

import java.util.Scanner;

public class Ok {
    public static int Fib(int num) {
        if (num == 0 || num == 1)
            return num;
        else
            return Fib(num - 2) + Fib(num - 1);
    }

    public static void main(String[] args) {
        System.out.println(Fib(6));

    }
}

Similiar Collections

Python strftime reference pandas.Period.strftime python - Formatting Quarter time in pandas columns - Stack Overflow python - Pandas: Change day - Stack Overflow python - Check if multiple columns exist in a df - Stack Overflow Pandas DataFrame apply() - sending arguments examples python - How to filter a dataframe of dates by a particular month/day? - Stack Overflow python - replace a value in the entire pandas data frame - Stack Overflow python - Replacing blank values (white space) with NaN in pandas - Stack Overflow python - get list from pandas dataframe column - Stack Overflow python - How to drop rows of Pandas DataFrame whose value in a certain column is NaN - Stack Overflow python - How to drop rows of Pandas DataFrame whose value in a certain column is NaN - Stack Overflow python - How to lowercase a pandas dataframe string column if it has missing values? - Stack Overflow How to Convert Integers to Strings in Pandas DataFrame - Data to Fish How to Convert Integers to Strings in Pandas DataFrame - Data to Fish create a dictionary of two pandas Dataframe columns? - Stack Overflow python - ValueError: No axis named node2 for object type <class 'pandas.core.frame.DataFrame'> - Stack Overflow Python Pandas iterate over rows and access column names - Stack Overflow python - Creating dataframe from a dictionary where entries have different lengths - Stack Overflow python - Deleting DataFrame row in Pandas based on column value - Stack Overflow python - How to check if a column exists in Pandas - Stack Overflow python - Import pandas dataframe column as string not int - Stack Overflow python - What is the most efficient way to create a dictionary of two pandas Dataframe columns? - Stack Overflow Python Loop through Excel sheets, place into one df - Stack Overflow python - How do I get the row count of a Pandas DataFrame? - Stack Overflow python - How to save a new sheet in an existing excel file, using Pandas? - Stack Overflow Python Loop through Excel sheets, place into one df - Stack Overflow How do I select a subset of a DataFrame? — pandas 1.2.4 documentation python - Delete column from pandas DataFrame - Stack Overflow python - Convert list of dictionaries to a pandas DataFrame - Stack Overflow