Skip to content

Instantly share code, notes, and snippets.

View BT-ICD's full-sized avatar

Bhavin BT-ICD

  • ICD
  • Gujarat, India
View GitHub Profile
@BT-ICD
BT-ICD / EMPTable
Last active July 29, 2020 05:00
EMP Table to learn SQL
Table Name: EMP
Columns:
EMPNO [numeric](4, 0) NOT NULL PRIMARY KEY,
ENAME [varchar](10) NULL,
JOB [varchar](10) NULL,
MGR [numeric](4, 0) NULL,
HIREDATE [date] NULL,
SAL [numeric](7, 2) NULL,
COMM [numeric](7, 2) NULL,
@BT-ICD
BT-ICD / ArrayDemo1.java
Created January 16, 2021 13:02
getColumn particular column as one dimension integer array from two dimension integer array
public class ArrayDemo1 {
public static void main(String[] args) {
int[][] arr2D = { { 0, 1, 2 }, { 3, 4, 5 }, { 6, 7, 8 }, { 9, 5, 3 } };
int[] result = getColumn(arr2D,1);
System.out.println(result.length);
for(int data: result){
System.out.println(data);
}
}
@BT-ICD
BT-ICD / SwitchCaseDemoWeekDayName.java
Created January 16, 2021 16:37
Switch Case - To determine weekday name from a particular weekday number
/**
* About switch case
* Program to get weekday name. Initialize value with weekday number
* 0 - Sunday
* */
public class SwitchCaseDemoWeekDayName {
public static void main(String[] args) {
byte weekDayNum=0;
switch (weekDayNum){
@BT-ICD
BT-ICD / SwitchCaseDemoVowel.java
Created January 16, 2021 16:47
Switch case demo: To determine particular character is vowel or not.
/**
* To determine particular character is vowel or not.
* Switch case example
* */
public class SwitchCaseDemoVowel {
public static void main(String[] args) {
char ch='e';
//Converts the character to uppercase
ch = Character.toUpperCase(ch);
@BT-ICD
BT-ICD / DollarBillsDemo.java
Created January 16, 2021 16:49
Example of % (reminder) and integer division. Program to display various dollar bills required for particular dollar amount
/***
* American paper currency come in seven denominations: $1, $2, $5, $10, $20, $50, and $100.
* Write a program that display various dollar bills required for particular amount
*/
public class DollarBillsDemo {
public static void main(String[] args) {
int dollarAmount = 1285;
int d1,d2,d5,d10,d20,d50, d100, rem;
d100 = dollarAmount/100;
rem = dollarAmount%100;
@BT-ICD
BT-ICD / VariableArgumentsDemo.java
Created January 24, 2021 17:13
Example of Varaible Number of Arguments in function. Addition function with variable number of arguments
/**
* To learn about variable number of arguments to the function
* The three dots ( ... ) are used in a function's declaration as a parameter.
* These dots allow zero to multiple arguments to be passed when the function is called.
* The three dots are also known as var args .
* Varargs is a short name for variable arguments.
* */
public class VariableArgumentsDemo {
public static void main(String[] args) {
@BT-ICD
BT-ICD / ProfitLossDemo.java
Created January 24, 2021 17:36
Example of conditional execution. To determine profit or loss. Calculate amount as well as percentage of profit or loss.
public class ProfitLossDemo {
public static void main(String[] args) {
double costPrice, salesPrice,profitAmt,lossAmt, profitPercentage, lossPercentage;
costPrice=50;
salesPrice=50;
if(costPrice>salesPrice){
lossAmt= costPrice-salesPrice;
lossPercentage=100*lossAmt/costPrice;
System.out.println("Loss in amount "+ lossAmt);
System.out.println("Loss in % " + lossPercentage);
@BT-ICD
BT-ICD / LeapYearExample.java
Created January 24, 2021 18:09
Conditional Execution Demo- To determine particular year is a leap year or not.
/**
* To determine that particular year is a leap year or not
* Note:
* A year is a leap year if the following conditions are satisfied:
* The year is multiple of 400.
* The year is multiple of 4 and not multiple of 100.
* According to these rules, the years 2000 and 2400 are leap years, while 1800, 1900, 2100, 2200, 2300, and 2500 are not leap years.
* References:
* https://www.timeanddate.com/date/leapyear.html
* https://www.wikihow.com/Calculate-Leap-Years
@BT-ICD
BT-ICD / TimeDemo.java
Created January 25, 2021 04:36
Example of method overloading. MyTime Class with add method and Object argument.
/**
* Example of method overloading
*Create a class name MyTime as follows:
*
* List of data member
* 1. hours
* 2. minutes
* 3. seconds
*
* List of methods
@BT-ICD
BT-ICD / DetermineOutputDemo.java
Created January 28, 2021 16:12
Example to learn about tracing - Conditional Execution and Math Operator in JAVA
public class DetermineOutputDemo {
public static void main(String[] args) {
outputDemo7();
}
static void outputDemo1(){
//Output x is :2
int x;
x = 3*4%5;
System.out.println("x is :" + x);
}