Sie sind auf Seite 1von 11

Lab Report

Course Code : CSE 212


Course Title : Object Oriented Programming
Sessional

Submitted to:
Mohammad Aramanuzzaman
Lecturer
Department of Computer Science &
Engineering.
Port City International University.
Submitted by:
Name : Mohammad Jobair Shakib
ID : CSE 019 06831
Batch : 19th (A)
Date of Submission: 05-03-2020
Problem Type: String Class
Source Code :
public class W {

public static void main(String[] args) {

String s1="Welcome To Department of ";

System.out.println(s1);

char ch[]={'C','S','E'};

String s2=new String(ch);

System.out.println(s2);

String s3 = new String("19");

System.out.println(s3);

String s4=s1.toUpperCase();

System.out.println("UpperCase: "+s4);

String s8=s1.toLowerCase();

System.out.println("LowerCase: "+s8);

char s5=s1.charAt(4);

System.out.println("CharAt(4): "+s5);
String s6=s3.replace("19","20");

System.out.println("Replace instead of 19 to : "+s6);

String s7=s1.replaceAll("e","a");

System.out.println("ReplaceAll e to a: "+s7);

System.out.println("Length: "+s1.length());

System.out.println("Trim: "+s1.trim()+"CSE");

System.out.println("CompareTo(s1,s2): "+s1.compareTo(s2));

System.out.println("Concat: "+s1.concat(" CSE-19(A)"));

System.out.println("Contains: "+s1.contains("of"));

System.out.println("EndsWith: "+s1.endsWith("of"));

double a = 84352.24;

double b = 154.284;

System.out.println(Math.nextAfter(a, b));
}

Output:

Problem : 9.5
Source Code :
import java.util.Scanner;
public class StraightLine {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
int i,n;
float m = 1,c = 1,line;
System.out.println("How many points in the straight
line(n+1):");
n=input.nextInt();
int x[]=new int[n];
int y[]=new int[n];
System.out.println("Enter the points of X and Y:");
for(i=1;i<n;i++){
x[i]=input.nextInt();
y[i]=input.nextInt();
}
for(i=1;i<n;i++){
m=(n*(x[i]*y[i])-(x[i])*(y[i]))/(n*(x[i]*x[i])-(x[i]*x[i]));
c=(1/n)*(y[i]-m*x[i]);
System.out.println("m = "+m+" C = "+c);
}
for(i=1;i<n;i++){
line=m*x[i]+c;
System.out.println("y=mx+c : "+line);
}

}
}
Output:

Problem : 9.6
Source Code :
import java.util.Scanner;

public class Temperature {

public static void main(String[] args) {

Scanner input=new Scanner(System.in);

float cityday[][]=new float[10][31];

float max,min;

int i,j,m=1,n=1;

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

for(i=0;i<10;i++){
for(j=0;j<3;j++){

cityday[i][j]=input.nextFloat();

max=cityday[0][0];

for(i=0;i<10;i++){

for(j=0;j<3;j++){

if(max<cityday[i][j]){

max=cityday[i][j];

m=j+1;

n=i+1;

System.out.println("Max temperature :"+max+"\t in city no :"+m+"\t on


the day :"+n);

min=cityday[0][0];

m=1;n=1;

for(i=0;i<10;i++){

for(j=0;j<3;j++){

if(min>cityday[i][j]){

min=cityday[i][j];
m=j+1;

n=i+1;

System.out.println("Min temperature :"+min+"\t in city no :"+m+"\t on


the day :"+n);

Output:

Problem : 9.8
Source Code :
import java.util.Scanner;
public class Result {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
int a[][]=new int[5][4];
int sum[]={0,0,0,0,0};
int i,j,t;
System.out.println("Enter Roll,Marks in three Sub for 5
Students");
System.out.println("Roll\tSub_1\tSub_2\tSub_3");
for(i=0;i<5;i++){
for(j=0;j<4;j++){
a[i][j]=input.nextInt();
}
}
System.out.println("Roll\tSub_1\tSub_2\tSub_3");
for(i=0;i<5;i++){
for(j=0;j<4;j++){
System.out.print(a[i][j]+"\t");
}
System.out.println();
}
System.out.println();
for(i=0;i<5;i++){
sum[i]=a[i][1]+a[i][2]+a[i][3];
System.out.println("Sum["+i+"]"+"="+sum[i]);
}
for(i=0;i<5;i++){
for(j=0;j<4;j++){
if(sum[j]>sum[j+1]){
t=sum[j+1];
sum[j+1]=sum[j];
sum[j]=t;
}
}
System.out.println("Largest Value:= "+sum[j]);
}
}

}
Output: