Skip to content

Commit d849f5f

Browse files
authored
Add files via upload
1 parent f1cd8d2 commit d849f5f

File tree

5 files changed

+173
-0
lines changed

5 files changed

+173
-0
lines changed

BookRecord.java

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
package oopslab4;
2+
class Book //class
3+
{
4+
String name;
5+
public String getName() {
6+
return name;
7+
}
8+
9+
public void setName(String name) {
10+
this.name = name;
11+
}
12+
13+
public int getBookId() {
14+
return bookId;
15+
}
16+
17+
public void setBookId(int bookId) {
18+
this.bookId = bookId;
19+
}
20+
21+
public String getAuthorName() {
22+
return authorName;
23+
}
24+
25+
public void setAuthorName(String authorName) {
26+
this.authorName = authorName;
27+
}
28+
29+
public String getSession() {
30+
return session;
31+
}
32+
33+
public void setSession(String session) {
34+
this.session = session;
35+
}
36+
37+
int bookId;
38+
String authorName;
39+
String session;
40+
41+
42+
Book(String name, int bookId, String authorName, String session) //constructor having 4 parameter
43+
{
44+
this.name = name;
45+
this.bookId = bookId;
46+
this.authorName = authorName;
47+
this.session = session;
48+
}
49+
50+
Book(String name, String authorName, String session)//constructor having 3 parameter
51+
{
52+
this.name = name;
53+
this.authorName = authorName;
54+
this.session = session;
55+
}
56+
}
57+
58+
public class BookRecord //main class
59+
{
60+
private void detailsOfBook(Book book) //private method
61+
{
62+
System.out.println("Name of Book= "+ book.getName());
63+
System.out.println("Id of Book= "+ book.getBookId());
64+
System.out.println("Auther Name of Book= "+ book.getAuthorName());
65+
System.out.println("Session of Book= "+ book.getSession());
66+
}
67+
68+
public static void main (String arg[]) //main block
69+
{
70+
// Creating object and providing some values by using parameterized constructor
71+
Book bookOne = new Book("OBJECT ORIENTED PROGRAMMING", 1001, "O.K", "2022");
72+
Book bookTwo = new Book("APPLIED STATICS", 1003, "K.G", "2016");
73+
74+
Book bookThree = new Book("INTRO TO AI", "Q.U", "2019");
75+
76+
BookRecord bookRecord = new BookRecord();
77+
bookRecord.detailsOfBook(bookOne);
78+
bookRecord.detailsOfBook(bookTwo);
79+
bookRecord.detailsOfBook(bookThree);
80+
}
81+
}

Combinations.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package oopslab4;
2+
3+
import java.util.Scanner;
4+
public class Combinations {
5+
public static void main(String[] args){
6+
System.out.println("THE DIGITS MUST LIE FROM 0-9");
7+
Scanner sc=new Scanner(System.in);
8+
System.out.println("ENTER FIRST DIGIT- ");
9+
int x= sc.nextInt();
10+
System.out.println("ENTER SECOND DIGIT- ");
11+
int y= sc.nextInt();
12+
System.out.println("ENTER THIRD DIGIT- ");
13+
int z= sc.nextInt();
14+
int lst[]={x,y,z};
15+
for(int i = 0; i < 3; i++) {
16+
for(int j = 0; j < 3; j++) {
17+
for(int k = 0; k < 3; k++) {
18+
if(i!=j&j!=k&k!=i)
19+
System.out.println("POSSIBLE COMBINATION: "+lst[i]+lst[j]+lst[k]);
20+
}
21+
}
22+
}
23+
}
24+
}

Months.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package oopslab4;
2+
import java.util.Scanner;
3+
public class Months {
4+
public static void main(String[] args){
5+
Scanner sc=new Scanner(System.in);
6+
System.out.println("ENTER THE NUMBER YOU WANT MONTH FOR- ");
7+
int x= sc.nextInt();
8+
if(x==1)
9+
System.out.println("JANUARY");
10+
else if(x==2)
11+
System.out.println("FEBRUARY");
12+
else if(x==3)
13+
System.out.println("MARCH");
14+
else if(x==4)
15+
System.out.println("APRIL");
16+
else if(x==5)
17+
System.out.println("MAY");
18+
else if(x==6)
19+
System.out.println("JUNE");
20+
else if(x==7)
21+
System.out.println("JULY");
22+
else if(x==8)
23+
System.out.println("AUGUST");
24+
else if(x==9)
25+
System.out.println("SEPTEMBER");
26+
else if(x==10)
27+
System.out.println("OCTOBER");
28+
else if(x==11)
29+
System.out.println("NOVEMBER");
30+
else if(x==12)
31+
System.out.println("DECEMBER");
32+
else
33+
System.out.println("INVALID INPUT");
34+
}
35+
36+
}

Sqsum.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package oopslab4;
2+
//QUESTION 2
3+
import java.util.Scanner;
4+
public class Sqsum {
5+
public static void main(String[] args){
6+
int sum = 0;
7+
Scanner sc = new Scanner(System.in);
8+
int a[] = new int[10];
9+
System.out.println("ENTER ALL ELEMENT: ");
10+
for(int i = 0; i <10; i++)
11+
{
12+
a[i] = sc.nextInt();
13+
a[i]=a[i]*a[i];
14+
sum = sum + a[i];
15+
System.out.println("SQUARE OF NUMBERS: "+a[i]);
16+
17+
}
18+
System.out.println("SUM: "+sum);
19+
}
20+
21+
}

Sum.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package oopslab4;
2+
public class Sum {
3+
public static void main(String args[]) {
4+
int sum=0;
5+
for(int i=40;i<=250;i++) {
6+
if(i%5==0)
7+
sum=sum+i;
8+
}
9+
System.out.println("THE SUM OF NUMBERS FROM 40 TO 250 SIVISUBLE BY 5 IS= "+sum);
10+
}
11+
}

0 commit comments

Comments
 (0)