LAB 07

mail@pastecode.io avatar
unknown
java
16 days ago
3.1 kB
11
Indexable
Never
// Classwork One

import java.util.Scanner;

public class ClassworkOne {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String string_one = sc.nextLine();

        for (int i = 0; i < string_one.length() ; i++) {
            int ascii = string_one.codePointAt(i);
            if (ascii >= 97 && ascii <= 122) {
                int ascii_two = ascii - 32;
                char char_1 = (char) ascii_two;
                System.out.print(char_1);
            }
            else {
                char char_2 = (char) ascii;
                System.out.print(char_2);

            }

        }
    }
}

// Classwork Two

import java.util.Scanner;

public class ClassworkTwo {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.nextLine().toLowerCase();
        String reversed_a = "";
        boolean is_Palindrome = false;

        for(int i = a.length()-1; i >= 0; i--){
            reversed_a = reversed_a + a.charAt(i);
        }

        if (reversed_a.equals(a)) {
            is_Palindrome = true;
            System.out.println(is_Palindrome);
        }
        else {
            System.out.print(is_Palindrome);
        }

    }

}

// Classwork Three

import java.util.Scanner;
public class ClassworkThree {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String string_one = sc.nextLine();
        char char_one = sc.next().charAt(0);

        for (int i = 0; i < string_one.length(); i++) {
            char c = string_one.charAt(i);
            if (c == char_one) {
                System.out.println();
            }
            else {
                System.out.print(c);
            }
        }
    }
}


// Classeval One

import java.util.Scanner;

public class ClassEvalOne {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.nextLine();
        String reversed_a = "";

        for(int i = a.length()-1; i >= 0; i--){
            reversed_a = reversed_a + a.charAt(i);
        }


        System.out.println(reversed_a);
    }

}

// Classeval Two

import java.util.Scanner;

public class ClassEvalTwo {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String string_one = sc.nextLine().toLowerCase();

        int vowelCount = 0;
        int consonantCount = 0;

        for (int i = 0; i < string_one.length(); i++) {
            char ch = string_one.charAt(i);
            if (ch >= 'a' && ch <= 'z') {
                if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u') {
                    vowelCount++;
                } else {
                    consonantCount++;
                }
            }
        }

        if (vowelCount % 3 == 0 && consonantCount % 5 == 0 && vowelCount > 0 && consonantCount > 0) {
            System.out.println("Aaarr! Me Plunder!!");
        } else {
            System.out.println("Blimey! No Plunder!!");
        }
    }
}

Leave a Comment