Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
5e54ad3
Update Exercise 4.1.java
GowthamRam2000 Aug 28, 2019
b27a2ea
Merge pull request #1 from gowthamram2000/gowthamram2000-patch-1
GowthamRam2000 Aug 28, 2019
e946b08
Create week5
GowthamRam2000 Sep 6, 2019
789ab42
Delete week5
GowthamRam2000 Sep 6, 2019
e0d6be1
Create 1
GowthamRam2000 Sep 6, 2019
d116dc9
Create 2
GowthamRam2000 Sep 6, 2019
c856829
Create 3
GowthamRam2000 Sep 6, 2019
ed07339
Create 4
GowthamRam2000 Sep 6, 2019
fc95f48
Create 5
GowthamRam2000 Sep 6, 2019
757829d
Create file 1
GowthamRam2000 Sep 14, 2019
aa4d64a
Create week2
GowthamRam2000 Sep 14, 2019
e47424d
Delete week2
GowthamRam2000 Sep 14, 2019
108b73f
Create file-2
GowthamRam2000 Sep 14, 2019
c95ebd1
Create file-3
GowthamRam2000 Sep 14, 2019
90622b1
Create file-4
GowthamRam2000 Sep 14, 2019
598640c
Create file-5
GowthamRam2000 Sep 14, 2019
0dd34ff
Update file-3
GowthamRam2000 Sep 14, 2019
25dfb2c
Update file-3
GowthamRam2000 Sep 14, 2019
19746c4
Update file-3
GowthamRam2000 Sep 14, 2019
d37922a
Create program 1
GowthamRam2000 Sep 21, 2019
fb55748
Create program 2
GowthamRam2000 Sep 21, 2019
51d8100
Create program 3
GowthamRam2000 Sep 21, 2019
c867cc2
Create program 4
GowthamRam2000 Sep 21, 2019
b5206c3
Create program 5
GowthamRam2000 Sep 21, 2019
b437f70
Update program 1
GowthamRam2000 Sep 21, 2019
0efe767
Update program 2
GowthamRam2000 Sep 21, 2019
b190512
Update program 3
GowthamRam2000 Sep 21, 2019
258a8f2
Update program 4
GowthamRam2000 Sep 21, 2019
135dd32
Update program 5
GowthamRam2000 Sep 21, 2019
052eb65
Create program 3
GowthamRam2000 Sep 27, 2019
634b377
Create program 2
GowthamRam2000 Sep 27, 2019
1ea3c10
Create program 1
GowthamRam2000 Sep 27, 2019
3c5db83
Create PROGRAM 3
GowthamRam2000 Sep 27, 2019
e248c2f
Create PROGRAM 5
GowthamRam2000 Sep 27, 2019
0c92691
Delete PROGRAM 5
GowthamRam2000 Oct 2, 2019
646a88e
Delete PROGRAM 3
GowthamRam2000 Oct 2, 2019
bba5b19
Create Program5
GowthamRam2000 Oct 2, 2019
7dc1dcf
Update program 1
GowthamRam2000 Oct 2, 2019
847b2ed
Update program 2
GowthamRam2000 Oct 2, 2019
6b28fa0
Create program3
GowthamRam2000 Oct 2, 2019
00af72f
Create program4
GowthamRam2000 Oct 2, 2019
09c6b91
Create Borrowbook
GowthamRam2000 Nov 15, 2019
ebc217c
Created using Colaboratory
GowthamRam2000 Dec 14, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 119 additions & 0 deletions Borrowbook
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@

public class Library {
String address;
java.util.ArrayList<Book> books;

public static final String openTime = "9am";
public static final String closeTime = "5pm";

public Library(String libraryAddress) {
address = libraryAddress;
books = new java.util.ArrayList<Book>();
}

public void addBook(Book book) {
books.add(book);
}

public static void printOpeningHours() {
System.out.println("Libraries are open daily from " + openTime + " to " + closeTime);
}

public void printAddress() {
System.out.println(address);
}

public void printAvailableBooks() {
boolean bookPresent = false;
for (Book book : books) {
if (!book.isBorrowed()) {
System.out.println(book.getTitle());
bookPresent = true;
}
}
if (!bookPresent) {
System.out.println("No book in catalog");
}
}

public void borrowBook(String title) {
int found = 0;
for (Book book : books) {
if (book.getTitle().equals(title)) {
if (found == 0) {
found = 1;
}
if (!book.isBorrowed()) {
book.borrowed();
found = 2;
break;
};
}
}
if (found == 0) {
System.out.println("Sorry, this book is not in our catalog.");
} else if (found == 1) {
System.out.println("Sorry, this book is already borrowed.");
} else if (found == 2) {
System.out.println("You successfully borrowed " + title);
}
}

public void returnBook(String title) {
boolean found = false;
for (Book book : books) {
if (book.getTitle().equals(title) && book.isBorrowed()) {
book.returned();
found = true;
break;
}
}
if (found) {
System.out.println("You successfully returned " + title);
}
}

public static void main(String[] args) {
// Create two libraries
Library firstLibrary = new Library("10 Main St.");
Library secondLibrary = new Library("228 Liberty St.");

// Add four books to the first library
firstLibrary.addBook(new Book("The Da Vinci Code"));
firstLibrary.addBook(new Book("Le Petit Prince"));
firstLibrary.addBook(new Book("A Tale of Two Cities"));
firstLibrary.addBook(new Book("The Lord of the Rings"));

// Print opening hours and the addresses
System.out.println("Library hours:");
printOpeningHours();
System.out.println();

System.out.println("Library addresses:");
firstLibrary.printAddress();
secondLibrary.printAddress();
System.out.println();
System.out.println("Borrow Percyjackson s:");
firstLibrary.borrowBook("Percyjackson");
firstLibrary.borrowBook("Percyjackson");
secondLibrary.borrowBook("Percyjackson");
System.out.println();

// Print the titles of all available books from both libraries
System.out.println("Books available in the first library:");
firstLibrary.printAvailableBooks();
System.out.println();
System.out.println("Books available in the second library:");
secondLibrary.printAvailableBooks();
System.out.println();

// Return
System.out.println("Returning The Lord of the Rings:");
firstLibrary.returnBook("The Lord of the Rings");
System.out.println();

// Print the titles of available from the first library
System.out.println("Books available in the first library:");
firstLibrary.printAvailableBooks();
}
}
1,917 changes: 1,917 additions & 0 deletions Copy_of_Detectron2_Tutorial.ipynb

Large diffs are not rendered by default.

16 changes: 2 additions & 14 deletions week 4/Exercise 4.1.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
// The following is the declaration of the main class named Question42
public class Question42 {
public static void main(String args[]){
int year; // integer type variable to store year

// Create an object of Calendar class.
java.util.Calendar current;
// Use getInstance() method to initialize the Calendar object.
current=java.util.Calendar.getInstance();
// Initialize the int variable year with the current year
year= current.get(java.util.Calendar.YEAR);
// Print the current Year
System.out.println("Current Year: "+year);
}
}
import static java.lang.System.out;
import java.util.Scanner;
11 changes: 11 additions & 0 deletions week 7/program 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Write the appropriate statement(s) to import the package(s) you need in your program
//ONLY SPECIFIC CODE SNIPPET IS GIVEN BECAUSE I WAS LAZY!!
import java.util.*;
public class Question1{
public static void main (String[] args){
//Write the appropriate code to read the 3 integer values and find their sum.
Scanner obj = new Scanner(System.in);
int a = obj.nextInt();
int b = obj.nextInt();
int c = obj.nextInt(); int sum = a+b+c;

11 changes: 11 additions & 0 deletions week 7/program 2
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//Use appropriate Try..catch block to complete the code
//ONLY SPECIFIC CODE SNIPPET IS GIVEN BECAUSE I WAS LAZY!!
try{
InputStreamReader r=new InputStreamReader(System.in);
BufferedReader br=new BufferedReader(r);
String number=br.readLine();
int x = Integer.parseInt(number);
System.out.print(x*x);
}catch(Exception e){
System.out.print("Please enter valid data");
}
5 changes: 5 additions & 0 deletions week 7/program 3
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Complete the code to get specific indexed byte value and its corresponding char value
////ONLY SPECIFIC CODE SNIPPET IS GIVEN BECAUSE I WAS LAZY!!
System.out.println(barr[n]);
System.out.print((char)barr[n]); }

9 changes: 9 additions & 0 deletions week 7/program 4
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//Write your code here to count the number of vowels in the string "s1"
////ONLY SPECIFIC CODE SNIPPET IS GIVEN BECAUSE I WAS LAZY!!
s1 = s1.toLowerCase();
for(int i=0;i<s1.length();i++){
char word = s1.charAt(i);
if(word =='a' || word == 'e' || word == 'i' || word == 'o' || word == 'u'){
c = c+1; }
}

6 changes: 6 additions & 0 deletions week 7/program 5
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//Replace the char in string "s1" with the char 'a' at index "n" and print the modified string
////ONLY SPECIFIC CODE SNIPPET IS GIVEN BECAUSE I WAS LAZY!!
StringBuilder string = new StringBuilder(s1);
string.setCharAt(n,c);
System.out.print(string);
}
19 changes: 19 additions & 0 deletions week 8/program 3
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import java.util.*;
public class Pattern3 {
public static void main(String[] args) {
Scanner inr = new Scanner(System.in);
int n = inr.nextInt();
// Add the necessary code in the below space
for (int i = 0; i < n; i++) {
int number = 1;
System.out.printf("%" + (n - i) * 2 + "s", "");
for (int j = 0; j <= i; j++) {
System.out.printf("%4d", number);
number = number * (i - j) / (j + 1);
}
System.out.println();
}

}

}
22 changes: 22 additions & 0 deletions week5/1
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import java.util.Scanner;
interface Number {
int findSqr(int i); // Returns the square of n
}

//Create a class A which implements the interface Number.
class A implements Number
{
public int findSqr(int i) {
return i*i;
}
}

public class Question5_1{
public static void main (String[] args){
A a = new A(); //Create an object of class A
// Read a number from the keyboard
Scanner sc = new Scanner(System.in);
int i = sc.nextInt();
System.out.print(a.findSqr(i));
}
}
31 changes: 31 additions & 0 deletions week5/2
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import java.util.Scanner;

interface GCD {
public int findGCD(int n1,int n2);
}

//Create a class B, which implements the interface GCD.
class B implements GCD
{
public int findGCD(int n1,int n2)
{

if(n2 == 0)
{
return n1;
}
return findGCD(n2,n2%n1);

}
}

public class Question5_2{
public static void main (String[] args){
B a = new B(); //Create an object of class B
// Read two numbers from the keyboard
Scanner sc = new Scanner(System.in);
int p1 = sc.nextInt();
int p2 = sc.nextInt();
System.out.print(a.findGCD(p1,p2));
}
}
20 changes: 20 additions & 0 deletions week5/3
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import java.util.Scanner;

public class Question5_3 {
public static void main(String[] args) {
int a, b;
Scanner input = new Scanner(System.in);


//Read any two values for a and b.
a = input.nextInt();
b = input.nextInt();
//Get the result of a/b;
try{
System.out.print(a/b);
}catch(ArithmeticException e){
System.out.print("Exception caught: Division by zero.");
}

}
}
31 changes: 31 additions & 0 deletions week5/4
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//Prefixed Fixed Code:
import java.util.*;
public class Question5_4{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int length = sc.nextInt();
// create an array to save user input
int[] name = new int[length];
int sum=0;//save the total sum of the array.

//Define try-catch block to save user input in the array "name",if there is an exception then catch the exception otherwise print the total sum of the array.
for(int i=0 ; i<length ; i++)
{
try{
name[i] = sc.nextInt();
sum += name[i];
}catch(InputMismatchException e){
sum = -1;
}
}
if(sum == -1)
{
System.out.print("You entered bad data.");
}
else
{
System.out.print(sum);
}

}
}
31 changes: 31 additions & 0 deletions week5/5
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import java.util.Scanner;
public class Question5_5{
public static void main (String args[ ] ) {
Scanner scan = new Scanner(System.in);
int i = scan.nextInt();
int j;

// Put the following code under try-catch block to handle exceptions
try{
switch (i) {
case 0 :
int zero = 0;
j = 92/ zero;
break;
case 1 :
int b[ ] = null;
j = b[0] ;
break;
default:
System.out.println("No exception");
}
}
catch(Exception e)
{
System.out.print(e);
}


}
}

23 changes: 23 additions & 0 deletions week6/file 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//Complete the code segment to print the following using the concept of extending the Thread class in Java:

-----------------OUTPUT-------------------

Thread is Running.

-------------------------------------------------

// Write the appropriate code to extend the Thread class to complete the class Question61.
public class Question61 extends Thread{
public void run(){
System.out.print("Thread is Running.");
}

public static void main(String args[]){

// Creating object of thread class
Question61 thread=new Question61();

// Start the thread
thread.start();
}
}
15 changes: 15 additions & 0 deletions week6/file-2
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class ThreadRun implements Runnable {
public void run(){
System.out.print("Thread using Runnable interface.");
}
}

// Create main class Question62 with main() method and appropriate statements in it
public class Question62{
public static void main(String[] args){
ThreadRun obj = new ThreadRun();
Thread obj2 = new Thread(obj);
obj2.start();

}
}
Loading