STRING OPERATIONS
package stringoperations;
import [Link];
public class STRINGOPERATIONS {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
String first = "", second = "";
Scanner sc = new Scanner([Link]);
[Link]("String Operation");
[Link]();
[Link]("Enter the first Sting: ");
first = [Link]();
[Link]("Enter the second Sting: ");
second = [Link]();
[Link]("The strings are: " + first + " , " + second);
[Link]("The length of the first string is :" + [Link]());
[Link]("The length of the second string is :" + [Link]());
[Link]("The concatenation of first and second string is :" + [Link](" " + second));
[Link]("The first character of " + first + " is: " + [Link](0));
[Link]("The uppercase of " + first + " is: " + [Link]());
[Link]("The lowercase of " + first + " is: " + [Link]());
if ([Link]() != [Link]()) {
[Link](first + " and " + second + " are not same.");
} else {
[Link](first + " and " + second + " are same.");
ASCENDING AND DESCENDING ORDER
package q2ass;
import [Link];
public class Q2ass {
public static void main(String[] args) {
//Create Object for Scanner class to get input from keyword
Scanner scn = new Scanner([Link]);
[Link]("Enter the size of an array: ");
//Set array size
int size = [Link](), temp;
//Get input from keyword
[Link]("Enter array values\n");
int[] arr = new int[size];
//Get all input from keyword
for(int i =0; i<size;i++){
arr[i]=[Link]();
}
//Validate the element for ascending sort order
for(int m=0;m<[Link];m++){
for(int n=m+1;n<[Link];n++){
if(arr[m]>arr[n]){
temp = arr[m];
arr[m]=arr[n];
arr[n]=temp;
}
}
}
//Display the ascending order of given elememts
[Link]("ascending order are: \n");
for(int t: arr){
[Link](t);
}
//Validate the element for descending sort order
for(int m=0;m<[Link];m++){
for(int n=m+1;n<[Link];n++){
if(arr[m]<arr[n]){
temp = arr[m];
arr[m]=arr[n];
arr[n]=temp;
}
}
}
//Display the descending order
[Link]("descending order are: \n");
for(int t: arr){
[Link](t);
}
}
}
RECTANGLE
import [Link].*;
public class rectangle{
int width,length;
String color;
void get_length(int a)
{
length=a;
}
void get_width(int a)
{
width=a;
}
String get_color(String a)
{
color=a;
return(color);
}
int find_area()
{
return(width*length);
}
String getcolor()
{
return(color);
}
public static void main(String arg[])throws Exception
{
String s=null;
DataInputStream in=new DataInputStream([Link]);
rectangle a=new rectangle();
[Link]("Enter the length for first rectangle");
s=[Link]();
a.get_length([Link](s));
[Link]("Enter the width for first rectangle");
s=[Link]();
a.get_width([Link](s));
[Link]("Enter the Color for first rectangle");
a.get_color([Link]());
rectangle b=new rectangle();
[Link]("Enter the length for second rectangle");
s=[Link]();
b.get_length([Link](s));
[Link]("Enter the width for second rectangle");
s=[Link]();
b.get_width([Link](s));
[Link]("Enter the Color for second rectangle");
b.get_color([Link]());
if(a.find_area()==b.find_area() && [Link]().equals([Link]()))
[Link]("Matching Rectangle ");
else
[Link]("Non Matching Rectangle ");
}
}