Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assignments1 #1295

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"java.project.sourcePaths": ["src"],
"java.project.outputPath": "bin",
"java.project.referencedLibraries": [
"lib/**/*.jar"
]
}
Original file line number Diff line number Diff line change
@@ -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).
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
public class App {
public static void main(String[] args) throws Exception {
System.out.println("Hello, World!");
}
}
7 changes: 7 additions & 0 deletions MyLearning/Assignments/FlowOfProgram/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"java.project.sourcePaths": ["src"],
"java.project.outputPath": "bin",
"java.project.referencedLibraries": [
"lib/**/*.jar"
]
}
18 changes: 18 additions & 0 deletions MyLearning/Assignments/FlowOfProgram/README.md
Original file line number Diff line number Diff line change
@@ -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).
5 changes: 5 additions & 0 deletions MyLearning/Assignments/FlowOfProgram/src/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
public class App {
public static void main(String[] args) throws Exception {
System.out.println("Hello, World!");
}
}
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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();
}

}
Original file line number Diff line number Diff line change
@@ -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;
}
}
}

Original file line number Diff line number Diff line change
@@ -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();
}
}
Original file line number Diff line number Diff line change
@@ -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();

}

}
Original file line number Diff line number Diff line change
@@ -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();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<schema><column comment="" default="" key="false" label="Id" length="18" nullable="false" originalDbColumnName="Id" pattern="" precision="-1" talendType="id_String"/><column comment="" default="" key="false" label="OwnerId" length="18" nullable="false" originalDbColumnName="OwnerId" pattern="" precision="-1" talendType="id_String"/><column comment="" default="" key="false" label="IsDeleted" length="-1" nullable="false" originalDbColumnName="IsDeleted" pattern="" precision="-1" talendType="id_Boolean"/><column comment="" default="" key="false" label="Name" length="80" nullable="false" originalDbColumnName="Name" pattern="" precision="-1" talendType="id_String"/><column comment="" default="" key="false" label="CreatedDate" length="-1" nullable="false" originalDbColumnName="CreatedDate" pattern="&quot;yyyy-MM-dd'T'HH:mm:ss'.000Z'&quot;" precision="-1" talendType="id_Date"/><column comment="" default="" key="false" label="CreatedById" length="18" nullable="false" originalDbColumnName="CreatedById" pattern="" precision="-1" talendType="id_String"/><column comment="" default="" key="false" label="LastModifiedDate" length="-1" nullable="false" originalDbColumnName="LastModifiedDate" pattern="&quot;yyyy-MM-dd'T'HH:mm:ss'.000Z'&quot;" precision="-1" talendType="id_Date"/><column comment="" default="" key="false" label="LastModifiedById" length="18" nullable="false" originalDbColumnName="LastModifiedById" pattern="" precision="-1" talendType="id_String"/><column comment="" default="" key="false" label="SystemModstamp" length="-1" nullable="false" originalDbColumnName="SystemModstamp" pattern="&quot;yyyy-MM-dd'T'HH:mm:ss'.000Z'&quot;" precision="-1" talendType="id_Date"/><column comment="" default="" key="false" label="OpportunityTeamMember_ID__c" length="18" nullable="false" originalDbColumnName="OpportunityTeamMember_ID__c" pattern="" precision="-1" talendType="id_String"/><column comment="" default="" key="false" label="Related_To_Opportunity__c" length="18" nullable="true" originalDbColumnName="Related_To_Opportunity__c" pattern="" precision="-1" talendType="id_String"/></schema>
66 changes: 66 additions & 0 deletions MyLearning/Assignments/FlowOfProgram/src/com/ajit/XMLParser.java
Original file line number Diff line number Diff line change
@@ -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<columnList.getLength();i++){
Node column=columnList.item(i);
if(column.getNodeType()==Node.ELEMENT_NODE){
Element columnElement=(Element)column;

String colname=columnElement.getAttribute("originalDbColumnName");
String len=columnElement.getAttribute("length");
String nullable=columnElement.getAttribute("nullable");
String type=columnType(columnElement.getAttribute("talendType"),len,colname,nullable);
String comma_no_comma=(columnList.getLength()-i==1)?"":",";

System.out.println(colname
+
' '
+type+comma_no_comma);
}
}
} catch (ParserConfigurationException | SAXException | IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public static String columnType(String str,String length, String colname,String nullable){
str=str.replace("id_", "");
if(colname.equals("LastModifiedDate")||colname.equals("SystemModstamp")||colname.equals("CreatedDate")){
str= "TIMESTAMP WITH LOCAL TIME ZONE";
}

if(str.equals("String")){
str= "varchar2("+length+")";
}

if(str.equals("Boolean")){
str="varchar2(1)";
}
if(nullable.equals("false")){
str=str+" not null";
}
//System.out.println(nullable);
return str;
}
}
11 changes: 11 additions & 0 deletions MyLearning/Assignments/FlowOfProgram/src/com/ajit/test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.ajit;

public class test {
public static void main(String[] args) {
String s="id_string";
String result=s.replace("id_","");
System.out.println(result);
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "TypeCasting2",
"request": "launch",
"mainClass": "com.ajit.TypeCasting2",
"projectName": "FirstJavaProgram_bbb8df63"
},
{
"type": "java",
"name": "TypeCasting",
"request": "launch",
"mainClass": "com.ajit.TypeCasting",
"projectName": "FirstJavaProgram_bbb8df63"
},
{
"type": "java",
"name": "sumOfTwoNumbers",
"request": "launch",
"mainClass": "com.ajit.sumOfTwoNumbers",
"projectName": "FirstJavaProgram_bbb8df63"
},
{
"type": "java",
"name": "Current File",
"request": "launch",
"mainClass": "${file}"
},
{
"type": "java",
"name": "Hello",
"request": "launch",
"mainClass": "com.ajit.Hello",
"projectName": "FirstJavaProgram_bbb8df63"
},
{
"type": "java",
"name": "Inputs",
"request": "launch",
"mainClass": "com.ajit.Inputs",
"projectName": "FirstJavaProgram_bbb8df63"
},
{
"type": "java",
"name": "Primitives",
"request": "launch",
"mainClass": "com.ajit.Primitives",
"projectName": "FirstJavaProgram_bbb8df63"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"java.project.sourcePaths": ["src"],
"java.project.outputPath": "bin",
"java.project.referencedLibraries": [
"lib/**/*.jar"
]
}
Original file line number Diff line number Diff line change
@@ -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).
Original file line number Diff line number Diff line change
@@ -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());
}

}
Loading