Oops University Asked Programs
Oops University Asked Programs
Write a java program to find the greatest of three number(6) (Dec 2022)
import java.util.Scanner;
a = sc.nextInt();
b = sc.nextInt();
c = sc.nextInt();
temp=a>b?a:b;
//comparing the temp variable with c and storing the result in the variable
largest=c>temp?c:temp;
} }
Output:
23
11
67
}}
Calendar c = Calendar.getInstance();
c.setTime(currdate);
c.add(Calendar.MONTH, 1);
Date lastdate= c.getTime();
returndate[i]=dateFormat.format(lastdate);
flag=1;
}}
if(flag==0)
System.out.println("book is not found");
}
if(flag==1)
System.out.println("currently available for drawbook");
}
{
System.out.println("currently available");
status[i]=1;
System.out.println("book is reserved");
flag=1;
}}
if(flag==0)
{
System.out.println("currently not available");
}
if(one.getTime()>two.getTime())
{
long difference = (one.getTime()-two.getTime())/86400000;
System.out.println("fine :" +((Math.abs(difference))*5));
}
else
System.out.println("fine : nil");
}
catch(Exception e)
{}
}
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
int j,i=1;
Scanner in=new Scanner(System.in);
while( i==1)
{
System.out.println("1.drawbook\n2.checkstatus\n3.returnbook\n4.reservebook");
System.out.println("enter option");
int op=in.nextInt();
switch(op)
{
case 1:
b.drawbook();
break;
case 2:
b.checkstatus();
break;
case 3:
b.returnbook();
break;
case 4:
b.reservebook();
break;
default:
System.out.println("invalid option ");
}
System.out.println("do u want to continue 1.y/2.n ");
j=in.nextInt();
if(j==2)
i=0;
}
output:
1.drawbook
2.checkstatus
3.returnbook
4.reservebook
enter option
1
Enter the title to search
java
book is found
do u want to continue 1.y/2.n
1
1.drawbook
2.checkstatus
3.returnbook
4.reservebook
enter option
2
Enter the title to check status
java
currently not available
The book draw date03/09/2018
The book should return on or before:03/10/2018
do u want to continue 1.y/2.n
1
1.drawbook
2.checkstatus
3.returnbook
4.reservebook
enter option
4
Enter the title to reserve book
oops
currently available
book is reserved
do u want to continue 1.y/2.n
1
1.drawbook
2.checkstatus
3.returnbook
4.reservebook
enter option
3
Enter the title of book to be return
java
fine : nil
the book is returned
do u want to continue 1.y/2.n
2
4. Explain how inner classes and anonymous classes works in java program.