0% found this document useful (0 votes)
18 views5 pages

ASSIGNMENT06 24121148 Abeed

Uploaded by

Abdullah Abeed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views5 pages

ASSIGNMENT06 24121148 Abeed

Uploaded by

Abdullah Abeed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

//Task1

import java.util.Scanner;
public class Task1 {
public static void main(String[] args) {
Scanner abeed= new Scanner(System.in);
System.out.println("Please enter your input");
String first = abeed.nextLine();
int count = first.length();

for(int i = 0;i<count;i++)
{
char ch = first.charAt(i);
int asc = (int)ch;

if(asc>=97 && asc<=122)


{
asc-=32;
char cap = (char)asc;
System.out.print(cap);
}
else
{
System.out.print(ch);
}
}
}
}

//Task2

import java.util.Scanner;
public class Task2 {
public static void main(String[] args) {
Scanner abeed= new Scanner(System.in);
System.out.println("Please enter your input");
String first = abeed.nextLine();
int count = first.length();
String rev="";

for(int i = count-1; i>=0 ;i--)


{
char ch = first.charAt(i);
rev+=ch;
}
System.out.println(rev);
if(rev.equals(first) )
{
System.out.println("true");
}
else
{
System.out.println("false");
}
}
}
//Task4
import java.util.Scanner;
public class Task4 {
public static void main(String[] args) {
Scanner abeed= new Scanner(System.in);
System.out.println("Please enter your input");
String first = abeed.nextLine();
int count = first.length();
String rev = "";
for(int i = count-1; i>=0 ;i--)
{
char ch = first.charAt(i);
rev+=ch;
}
System.out.println(rev);
}
}

//Task5
import java.util.Scanner;
public class Task5{
public static void main(String[] args){
Scanner abeed = new Scanner(System.in);
System.out.println("Enter the input:");
String str = abeed.nextLine();

int vow =0;


int con =0;

for(int i = 0; i< str.length();i++)


{
char ch= str.charAt(i);

if(ch =='a' || ch=='e'||ch =='i'||ch =='o'||ch=='u')


{
vow++;
}

else if(ch >='a' && ch <='z')


{
con++;
}
}

if(vow> 0 && con> 0 && vow %3 == 0 && con% 5 == 0)


{
System.out.println("Aaarr! Me Plunder!!");
}
else
{
System.out.println("Blimey! No Plunder!!");
}
}
}

//Task7
import java.util.Scanner;
public class Task7 {
public static void main(String[] args) {
Scanner abeed= new Scanner(System.in);
System.out.println("Please enter your input");
String first = abeed.nextLine();
System.out.println("Please enter your input");
String second = abeed.nextLine();
int count1 = first.length();
int count2 = second.length();

String result ="";


boolean bool = false;
for(int i = 0; i<count1 ;i++)
{
char ch1 = first.charAt(i);

for(int j = 0; count2>j ;j++)


{
char ch2 = second.charAt(j);
if(ch1==ch2)
{
bool = true;

}
if(bool== false)
{
result +=ch1;

}
bool= false;

for(int i = 0; i<count2 ;i++)


{
char ch1 = second.charAt(i);

for(int j = 0; count1>j ;j++)


{
char ch2 = first.charAt(j);
if(ch1==ch2)
{
bool = true;

}
if(bool== false)
{
result +=ch1;
}
bool= false;

}
System.out.println(result);
}
}

//Task9
import java.util.Scanner;
public class Task9 {
public static void main(String[] args) {
Scanner abeed = new Scanner(System.in);

System.out.println("Enter the password:");


String password = abeed.nextLine();

boolean hasUppercase= false;


boolean hasLowercase= false;
boolean hasDigit= false;
boolean hasSpecialChar= false;

if(password.length()>=8)
{
for(int i = 0; i < password.length(); i++)
{
char ch = password.charAt(i);

if(ch >='A'&& ch<='Z')


{
hasUppercase= true;
}

else if(ch >='a' && ch<='z')


{
hasLowercase= true;
}

else if(ch >='0' && ch<= '9')


{
hasDigit= true;
}

else if(!(ch >='A' && ch <='Z') && !(ch >='a' && ch<= 'z') && !(ch
>= '0' && ch <='9'))
{
hasSpecialChar= true;
}
}
}

boolean isStrongPassword = hasUppercase && hasLowercase && hasDigit &&


hasSpecialChar && password.length() >= 8;

if(isStrongPassword)
{
System.out.println("True");
}
else
{
System.out.println("False");
}

}
}

You might also like