diff --git a/MyLearning/2_Conditionals and Loops/Conditionals and Loops Lecture/.vscode/settings.json b/MyLearning/2_Conditionals and Loops/Conditionals and Loops Lecture/.vscode/settings.json new file mode 100644 index 000000000..e112a702a --- /dev/null +++ b/MyLearning/2_Conditionals and Loops/Conditionals and Loops Lecture/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/MyLearning/2_Conditionals and Loops/Conditionals and Loops Lecture/README.md b/MyLearning/2_Conditionals and Loops/Conditionals and Loops Lecture/README.md new file mode 100644 index 000000000..7c03a5324 --- /dev/null +++ b/MyLearning/2_Conditionals and Loops/Conditionals and Loops Lecture/README.md @@ -0,0 +1,18 @@ +## Getting Started + +Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code. + +## Folder Structure + +The workspace contains two folders by default, where: + +- `src`: the folder to maintain sources +- `lib`: the folder to maintain dependencies + +Meanwhile, the compiled output files will be generated in the `bin` folder by default. + +> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there. + +## Dependency Management + +The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies). diff --git a/MyLearning/2_Conditionals and Loops/Conditionals and Loops Lecture/src/App.java b/MyLearning/2_Conditionals and Loops/Conditionals and Loops Lecture/src/App.java new file mode 100644 index 000000000..0a839f9bf --- /dev/null +++ b/MyLearning/2_Conditionals and Loops/Conditionals and Loops Lecture/src/App.java @@ -0,0 +1,5 @@ +public class App { + public static void main(String[] args) throws Exception { + System.out.println("Hello, World!"); + } +} diff --git a/MyLearning/Assignments/FlowOfProgram/.vscode/settings.json b/MyLearning/Assignments/FlowOfProgram/.vscode/settings.json new file mode 100644 index 000000000..e112a702a --- /dev/null +++ b/MyLearning/Assignments/FlowOfProgram/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar" + ] +} diff --git a/MyLearning/Assignments/FlowOfProgram/README.md b/MyLearning/Assignments/FlowOfProgram/README.md new file mode 100644 index 000000000..7c03a5324 --- /dev/null +++ b/MyLearning/Assignments/FlowOfProgram/README.md @@ -0,0 +1,18 @@ +## Getting Started + +Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code. + +## Folder Structure + +The workspace contains two folders by default, where: + +- `src`: the folder to maintain sources +- `lib`: the folder to maintain dependencies + +Meanwhile, the compiled output files will be generated in the `bin` folder by default. + +> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there. + +## Dependency Management + +The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies). diff --git a/MyLearning/Assignments/FlowOfProgram/src/App.java b/MyLearning/Assignments/FlowOfProgram/src/App.java new file mode 100644 index 000000000..0a839f9bf --- /dev/null +++ b/MyLearning/Assignments/FlowOfProgram/src/App.java @@ -0,0 +1,5 @@ +public class App { + public static void main(String[] args) throws Exception { + System.out.println("Hello, World!"); + } +} diff --git a/MyLearning/Assignments/FlowOfProgram/src/com/ajit/Assignment_HCF_LCM.java b/MyLearning/Assignments/FlowOfProgram/src/com/ajit/Assignment_HCF_LCM.java new file mode 100644 index 000000000..fc89033ad --- /dev/null +++ b/MyLearning/Assignments/FlowOfProgram/src/com/ajit/Assignment_HCF_LCM.java @@ -0,0 +1,34 @@ +package com.ajit; + +import java.util.Scanner; + +public class Assignment_HCF_LCM{ + public static void main(String[] args) { + Scanner input=new Scanner(System.in); + System.out.println("Please enter number1:"); + int lowerNum=input.nextInt(); + System.out.println("Please enter number2:"); + int higherNum=input.nextInt(); + input.close(); + /*Fix lower and higher numbers */ + if(lowerNum>higherNum){ + int temp=lowerNum; + lowerNum=higherNum; + higherNum=temp; + } + int remainder=1; + int divisor,dividend; + divisor=lowerNum; + dividend=higherNum; + while(remainder!=0){ + remainder=dividend%divisor; + dividend=divisor; + if(remainder==0){break;} + divisor=remainder; + + } + System.out.println("HCF:"+divisor); + int lcm=(lowerNum*higherNum/divisor); + System.out.println("LCM:"+lcm); + } +} \ No newline at end of file diff --git a/MyLearning/Assignments/FlowOfProgram/src/com/ajit/Assignment_LeapYearChecker.java b/MyLearning/Assignments/FlowOfProgram/src/com/ajit/Assignment_LeapYearChecker.java new file mode 100644 index 000000000..a890cbf39 --- /dev/null +++ b/MyLearning/Assignments/FlowOfProgram/src/com/ajit/Assignment_LeapYearChecker.java @@ -0,0 +1,20 @@ +package com.ajit; +import java.util.Scanner; + +public class Assignment_LeapYearChecker{ + public static void main(String[] args) { + Scanner input=new Scanner(System.in); + System.out.println("Please enter a year:"); + int year=input.nextInt(); + //if((year%4==0 && year%100!=0)||(year%4==0 && year%100==0 && year%400==0)){ + if (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)){ + System.out.println("Year Entered is a Leap Year"); + } + else + { + System.out.println("Year Entered is not a Leap Year"); + } + input.close(); + } + +} \ No newline at end of file diff --git a/MyLearning/Assignments/FlowOfProgram/src/com/ajit/Assignment_LeapYearChecker_gpt.java b/MyLearning/Assignments/FlowOfProgram/src/com/ajit/Assignment_LeapYearChecker_gpt.java new file mode 100644 index 000000000..6fe62831f --- /dev/null +++ b/MyLearning/Assignments/FlowOfProgram/src/com/ajit/Assignment_LeapYearChecker_gpt.java @@ -0,0 +1,35 @@ +package com.ajit; +import java.util.Scanner; + + +public class Assignment_LeapYearChecker_gpt { + public static void main(String[] args) { + Scanner scanner = new Scanner(System.in); + + System.out.println("Enter a year: "); + int year = scanner.nextInt(); + + if (isLeapYear(year)) { + System.out.println(year + " is a leap year."); + } else { + System.out.println(year + " is not a leap year."); + } + + scanner.close(); + } + + public static boolean isLeapYear(int year) { + // Check if the year is divisible by 4 + if (year % 4 == 0) { + // If the year is also divisible by 100, check if it is divisible by 400 + if (year % 100 == 0) { + return year % 400 == 0; + } else { + return true; + } + } else { + return false; + } + } +} + diff --git a/MyLearning/Assignments/FlowOfProgram/src/com/ajit/Assignment_multiplicationTable.java b/MyLearning/Assignments/FlowOfProgram/src/com/ajit/Assignment_multiplicationTable.java new file mode 100644 index 000000000..fd9678802 --- /dev/null +++ b/MyLearning/Assignments/FlowOfProgram/src/com/ajit/Assignment_multiplicationTable.java @@ -0,0 +1,16 @@ +package com.ajit; + +import java.util.Scanner; + +public class Assignment_multiplicationTable { + public static void main(String[] args) { + Scanner input=new Scanner(System.in); + System.out.println("Please enter a number"); + int num=input.nextInt(); + for(int i=1;i<=12;i++){ + int result=i*num; + System.out.println(num+" * "+i+" = "+result); + } + input.close(); + } +} diff --git a/MyLearning/Assignments/FlowOfProgram/src/com/ajit/Assignment_sumOfNumbers.java b/MyLearning/Assignments/FlowOfProgram/src/com/ajit/Assignment_sumOfNumbers.java new file mode 100644 index 000000000..5f91a65bc --- /dev/null +++ b/MyLearning/Assignments/FlowOfProgram/src/com/ajit/Assignment_sumOfNumbers.java @@ -0,0 +1,18 @@ +package com.ajit; + +import java.util.Scanner; + +public class Assignment_sumOfNumbers { + public static void main(String[] args) { + Scanner input=new Scanner(System.in); + System.out.println("Please enter number1:"); + Float num1=input.nextFloat(); + System.out.println("Please enter number2:"); + Float num2=input.nextFloat(); + Float result=num1+num2; + System.out.println("Total:"+result); + input.close(); + + } + +} diff --git a/MyLearning/Assignments/FlowOfProgram/src/com/ajit/Assignment_sumofall.java b/MyLearning/Assignments/FlowOfProgram/src/com/ajit/Assignment_sumofall.java new file mode 100644 index 000000000..567f5282a --- /dev/null +++ b/MyLearning/Assignments/FlowOfProgram/src/com/ajit/Assignment_sumofall.java @@ -0,0 +1,17 @@ +package com.ajit; + +import java.util.Scanner; + +public class Assignment_sumofall { + public static void main(String[] args) { + Scanner input=new Scanner(System.in); + float result=0; + String in=input.next(); + while(!in.equals("x") && !in.equals("X")){ + result=result+ Integer.valueOf(in); + in=input.next(); + } + System.out.println("Total Sum:"+result); + input.close(); + } +} diff --git a/MyLearning/Assignments/FlowOfProgram/src/com/ajit/OpportunityTeamMemberDeleteHistory.xml b/MyLearning/Assignments/FlowOfProgram/src/com/ajit/OpportunityTeamMemberDeleteHistory.xml new file mode 100644 index 000000000..a1a62dcea --- /dev/null +++ b/MyLearning/Assignments/FlowOfProgram/src/com/ajit/OpportunityTeamMemberDeleteHistory.xml @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/MyLearning/Assignments/FlowOfProgram/src/com/ajit/XMLParser.java b/MyLearning/Assignments/FlowOfProgram/src/com/ajit/XMLParser.java new file mode 100644 index 000000000..46d7e0cd3 --- /dev/null +++ b/MyLearning/Assignments/FlowOfProgram/src/com/ajit/XMLParser.java @@ -0,0 +1,66 @@ +package com.ajit; + +import java.io.File; +import java.io.IOException; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.SAXException; + +public class XMLParser{ + public static void main(String[] args) { + DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance(); + try { + DocumentBuilder builder=factory.newDocumentBuilder(); + Document document= builder.parse(new File("C:\\Users\\agokaraj\\Desktop\\GIT\\DSA-Bootcamp-Java\\MyLearning\\Assignments\\FlowOfProgram\\src\\com\\ajit\\OpportunityTeamMemberDeleteHistory.xml")); + document.getDocumentElement().normalize(); + + NodeList columnList=document.getElementsByTagName("column"); + for(int i=0;i If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there. + +## Dependency Management + +The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies). diff --git a/MyLearning/First Java Program- IO, Debug, Datatypes/FirstJavaProgram/src/com/ajit/Hello.java b/MyLearning/First Java Program- IO, Debug, Datatypes/FirstJavaProgram/src/com/ajit/Hello.java new file mode 100644 index 000000000..03dc80415 --- /dev/null +++ b/MyLearning/First Java Program- IO, Debug, Datatypes/FirstJavaProgram/src/com/ajit/Hello.java @@ -0,0 +1,12 @@ +package com.ajit; + +import java.util.Scanner; + +public class Hello { + public static void main(String[] args){ + System.out.println("Hello World"); + Scanner input= new Scanner(System.in); + System.out.println( input.nextLine()); + } + +} \ No newline at end of file diff --git a/MyLearning/First Java Program- IO, Debug, Datatypes/FirstJavaProgram/src/com/ajit/Inputs.java b/MyLearning/First Java Program- IO, Debug, Datatypes/FirstJavaProgram/src/com/ajit/Inputs.java new file mode 100644 index 000000000..593a1d3bb --- /dev/null +++ b/MyLearning/First Java Program- IO, Debug, Datatypes/FirstJavaProgram/src/com/ajit/Inputs.java @@ -0,0 +1,12 @@ +package com.ajit; + +import java.util.Scanner; + +public class Inputs { + public static void main(String[] args) { + Scanner input=new Scanner(System.in); + System.out.print("Please enter some input number:"); + int rollnum=input.nextInt(); + System.out.println("Your rollnum is:"+rollnum); + } +} diff --git a/MyLearning/First Java Program- IO, Debug, Datatypes/FirstJavaProgram/src/com/ajit/Primitives.java b/MyLearning/First Java Program- IO, Debug, Datatypes/FirstJavaProgram/src/com/ajit/Primitives.java new file mode 100644 index 000000000..1bcecc9e1 --- /dev/null +++ b/MyLearning/First Java Program- IO, Debug, Datatypes/FirstJavaProgram/src/com/ajit/Primitives.java @@ -0,0 +1,30 @@ +package com.ajit; + +public class Primitives { + public static void main(String[] args) { + int rollnum=45; + char letter='e'; + float marks=64.32f; + /*NOTE: All Decimal values by default are of the type double. To make sure they are float + * we add the "f" at the end; + */ + double largeDecimalNumbers=452323432.3423432; + long largeInteger=4235452345245L; + /*NOTE: All integer values by default are of the type "int". To make sure they are long + * we add the "L" at the end; + */ + boolean check= true; + boolean check2=false; + + /*Class types of Primitives + * a. These are also called wrapper classes. Gives an additional set of functions + * we can run on the objects of these classes + */ + Integer rno=64; + String rno_s=rno.toString(); + + // for declaring large numbers use _ instead of , + int a = 234_000_000; + } + +} \ No newline at end of file diff --git a/MyLearning/First Java Program- IO, Debug, Datatypes/FirstJavaProgram/src/com/ajit/TypeCasting.java b/MyLearning/First Java Program- IO, Debug, Datatypes/FirstJavaProgram/src/com/ajit/TypeCasting.java new file mode 100644 index 000000000..90066d5ba --- /dev/null +++ b/MyLearning/First Java Program- IO, Debug, Datatypes/FirstJavaProgram/src/com/ajit/TypeCasting.java @@ -0,0 +1,11 @@ +package com.ajit; + +import java.util.Scanner; + +public class TypeCasting { + public static void main(String[] args) { + Scanner input= new Scanner(System.in); + float numb=input.nextFloat(); + System.out.println(numb); + } +} diff --git a/MyLearning/First Java Program- IO, Debug, Datatypes/FirstJavaProgram/src/com/ajit/TypeCasting2.java b/MyLearning/First Java Program- IO, Debug, Datatypes/FirstJavaProgram/src/com/ajit/TypeCasting2.java new file mode 100644 index 000000000..c61e9ef3f --- /dev/null +++ b/MyLearning/First Java Program- IO, Debug, Datatypes/FirstJavaProgram/src/com/ajit/TypeCasting2.java @@ -0,0 +1,13 @@ +package com.ajit; + +import java.util.Scanner; + +public class TypeCasting2 { + public static void main(String[] args) { + //explicit type casting or conversion + byte n=(byte)258; + //byte range is 1-256. over that range it does number%256-remainder + //meaning the below will print 257%256=1 + System.out.println(n); + } +} diff --git a/MyLearning/First Java Program- IO, Debug, Datatypes/FirstJavaProgram/src/com/ajit/sumOfTwoNumbers.java b/MyLearning/First Java Program- IO, Debug, Datatypes/FirstJavaProgram/src/com/ajit/sumOfTwoNumbers.java new file mode 100644 index 000000000..91e711d85 --- /dev/null +++ b/MyLearning/First Java Program- IO, Debug, Datatypes/FirstJavaProgram/src/com/ajit/sumOfTwoNumbers.java @@ -0,0 +1,13 @@ +package com.ajit; + +import java.util.Scanner; + +public class sumOfTwoNumbers { + public static void main(String[] args) { + Scanner input=new Scanner(System.in); + int num1=input.nextInt(); + int num2=input.nextInt(); + + System.out.println("Sum of two numbers:"+(int)(num1+num2)); + } +} diff --git a/MyLearning/First Java Program- IO, Debug, Datatypes/Hello.java b/MyLearning/First Java Program- IO, Debug, Datatypes/Hello.java new file mode 100644 index 000000000..aea5e9540 --- /dev/null +++ b/MyLearning/First Java Program- IO, Debug, Datatypes/Hello.java @@ -0,0 +1,8 @@ +public class Hello { + public static void main(String[] args) { + System.out.println(args[0]); + System.out.println(args[1]); + + } + +} \ No newline at end of file