0% found this document useful (0 votes)
12 views6 pages

2 9pdf

JAVA OOPDP Assignment

Uploaded by

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

2 9pdf

JAVA OOPDP Assignment

Uploaded by

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

Mayank Sengar

BTECH/10111/23

CSE-A

Q1)

import java.util.Scanner;

class Student{

int rollno;

String name;

double percentage;

public Student(){

this.rollno =0;

this.name="";

this.percentage=0.0;

public void setData(){

Scanner sc=new Scanner(System.in);

System.out.print("Enter Roll No. ");

this.rollno= sc.nextInt();

sc.nextLine();

System.out.print("Enter Name ");

this.name=sc.nextLine();

System.out.print("Enter percentage ");

this.percentage=sc.nextDouble();

public void printData(){


if(this.percentage>=80){

System.out.println("Roll No. " + this.rollno);

System.out.println("Name: " + this.name);

System.out.println("percentage: " + this.percentage);

public static void main(String arg[]){

Scanner sc=new Scanner(System.in);

Student[] students =new Student[4];

for(int i=0;i<4;i++){

students[i]= new Student();

students[i].setData();

for(int i=0;i<4;i++){

students[i].printData();

Q2)

import java.util.Scanner;

class Format{
int rollno;

int year;

public Format(){

this.rollno =0;

this.year=0;

public void setData(){

Scanner sc=new Scanner(System.in);

System.out.print("Enter Roll No.: ");

this.rollno= sc.nextInt();

sc.nextLine();

System.out.print("Enter Year: ");

this.year=sc.nextInt();

sc.nextLine();

public void printData(){

System.out.println("BTECH/"+this.rollno+"/"+this.year);

public static void main(String arg[]){

Scanner sc=new Scanner(System.in);

Format id =new Format();


id.setData();

id.printData();

Q3)

import java.util.Scanner;

class Search{

String str;

String wrd;

public void stringip(){

Scanner sc=new Scanner(System.in);

System.out.println("Enter a String: ");

this.str=sc.nextLine();

public void word(){

Scanner sc=new Scanner(System.in);

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

this.wrd=sc.nextLine();

System.out.println(str.contains(wrd));

}
public static void main(String arg[]){

Search id =new Search();

id.stringip();

id.word();

Q4)

import java.util.Scanner;

class Remove{

String str1;

String str2;

public void string1(){

Scanner sc=new Scanner(System.in);

System.out.println("Enter String1: ");

this.str1=sc.nextLine();

public void string2(){

Scanner sc=new Scanner(System.in);

System.out.println("Enter String2: ");

this.str2=sc.nextLine();
for(int i=0;i<str2.length();i++){

//taking char of the strings at positions in c (Personal comment :> )

char c=str2.charAt(i);

//converting char to string to replace it

str1=str1.replace(String.valueOf(c),"");

System.out.println(str1);

public static void main(String arg[]){

Remove id =new Remove();

id.string1();

id.string2();

You might also like