forked from tarunsinghofficial/HacktoberFest
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
103 changed files
with
6,473 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
### AARUSHI SINGH | ||
- Photo: https://avatars.githubusercontent.com/u/72039600?v=4 | ||
- Location: INDIA | ||
- Github: https://github.com/Aarushi1Singh | ||
*** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/***Insertion Sort Algorithm***/ | ||
|
||
//@Author : SoumyadipGhosh23 (GitHub: https://github.com/SoumyadipGhosh23) | ||
|
||
#include<stdio.h> | ||
#include<stdlib.h> | ||
|
||
void printArr(int* a, int n){ | ||
for(int i=0; i<n; i++){ | ||
printf("%d ",a[i]); | ||
} | ||
printf("\n"); | ||
} | ||
|
||
void insertionSort(int* a, int n){ | ||
int temp,j; | ||
for(int i =1; i<n; i++){ | ||
printf("working on the pass no: %d\n",i); | ||
temp = a[i]; | ||
j= i-1; | ||
while(j>=0 && a[j]>temp){ | ||
a[j+1]=a[j]; | ||
j--; | ||
} | ||
a[j+1]=temp; | ||
} | ||
} | ||
|
||
int main(){ | ||
//int arr[] = {2,36,1,31,10,27,11,78,80,45}; | ||
int arr[] = {1,2,3,4,5,6,7,8,9,10}; | ||
printArr(arr,10); | ||
insertionSort(arr,10); | ||
printArr(arr,10); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#include <iostream> | ||
#include <math.h> | ||
using namespace std; | ||
int main() | ||
{ | ||
int num1,num2; | ||
char Operator; | ||
cout<<"Enter First Integer: "; | ||
cin>>num1; | ||
cout<<"Enter Second Integer: "; | ||
cin>>num2; | ||
cout<<"Enter Operator: "; | ||
cin>>Operator; | ||
|
||
if (Operator=='+') | ||
cout<<num1<<" "<<Operator<<" "<<num2<<" = "<<num1+num2; | ||
else if (Operator=='-') | ||
cout<<num1<<" "<<Operator<<" "<<num2<<" = "<<num1-num2; | ||
else if (Operator=='*') | ||
cout<<num1<<" "<<Operator<<" "<<num2<<" = "<<num1*num2; | ||
else if (Operator=='/') | ||
{ if (num2==0) | ||
cout<<"Denominator should not be zero"; | ||
else | ||
cout<<num1<<" "<<Operator<<" "<<num2<<" = "<<num1/num2; | ||
} | ||
else if (Operator=='%') | ||
cout<<num1<<" "<<Operator<<" "<<num2<<" = "<<num1%num2; | ||
else if (Operator=='&&') | ||
cout<<num1<<" "<<Operator<<" "<<num2<<" = "<<num1&&num2; | ||
else if (Operator=='||') | ||
cout<<num1<<" "<<Operator<<" "<<num2<<" = "<<num1||num2; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
### Eshller | ||
- Photo: https://avatars.githubusercontent.com/u/73096495?v=4 | ||
- Location: India | ||
- Github: https://github.com/eshller | ||
*** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
### FAUSTINA LEONITA | ||
- Photo: https://images2.alphacoders.com/107/1078781.jpg | ||
- Location: Indonesia | ||
- Github: https://github.com/faustinaleo18 | ||
*** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Hithru De Alwis | ||
Photo: https://avatars.githubusercontent.com/u/56365929?s=400&u=82e0e36dfc3de808c5cc368966ff18460b644697&v=4 | ||
Location: Sri Lanka | ||
Github:https://github.com/Hithru |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
public class ArrayElement | ||
{ | ||
public static void main(String[] args) | ||
{ | ||
char[][] theArray = new char[][]{{'a', 'b', 'c'}, | ||
{'d', 'e', 'f'}, | ||
{'g', 'h', 'i'}}; | ||
|
||
for (int i = 0; i < 3; i++) | ||
{ | ||
for (int j = 0; j < 3; j++) | ||
{ | ||
if (theArray[i][j] == 'e') | ||
{ | ||
System.out.println(theArray[i][j]); | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import java.util.Random; | ||
|
||
public class Assignment | ||
{ | ||
public static void main(String[] args) | ||
{ | ||
int[][] matrixA =new int[2][2]; | ||
int[][] matrixB =new int[2][2]; | ||
int[][] matrixC =new int[2][2]; | ||
|
||
Random randomNum = new Random(); | ||
|
||
//Matrix A initialization | ||
for (int i = 0; i < 2; i++) | ||
{ | ||
for (int j = 0; j < 2; j++) | ||
{ | ||
matrixA[i][j] = randomNum.nextInt(10); | ||
} | ||
} | ||
|
||
//Matrix B initialization | ||
for (int i = 0; i < 2; i++) | ||
{ | ||
for (int j = 0; j < 2; j++) | ||
{ | ||
matrixB[i][j] = randomNum.nextInt(10); | ||
} | ||
} | ||
|
||
//Multiplication | ||
for (int i = 0; i < 2; i++) | ||
{ | ||
for(int j = 0; j < 2; j++) | ||
{ | ||
matrixC[i][j] = 0; | ||
for(int k = 0; k < 2; k++) | ||
{ | ||
matrixC[i][j] += (matrixA[i][k] * matrixB[k][j]); | ||
} | ||
} | ||
} | ||
|
||
//Output | ||
System.out.println("\nThe Product of The 2 Random Matrices Is:"); | ||
for ( int i = 0; i < 2; i++) | ||
{ | ||
System.out.print("(\t"); | ||
for ( int j = 0; j < 2; j++) | ||
{ | ||
System.out.printf("%d \t", matrixC[i][j]); | ||
|
||
} | ||
System.out.print(")\n"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
//Java my A$$ | ||
|
||
import java.util.Scanner; | ||
|
||
public class BMI { | ||
public static void main(String[] args){ | ||
|
||
Scanner input = new Scanner(System.in); | ||
|
||
System.out.println("BMI VALUES"); | ||
System.out.println("Underweight: less than 18.5"); | ||
System.out.println("Normal: between 18.5 and 24.9"); | ||
System.out.println("Overweight: between 25 and 29.9"); | ||
System.out.println("Obese: above 30\n"); | ||
|
||
double weight, height; | ||
double BMI; | ||
System.out.println("Enter Your Weight:"); | ||
weight=input.nextFloat(); | ||
System.out.println("Enter Your Height:"); | ||
height=input.nextFloat(); | ||
BMI=weight/(height*height); | ||
|
||
System.out.println("BMI is: " + BMI); | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
public class Account{ | ||
|
||
private String name; | ||
private double balance; | ||
|
||
public Account(String name, double balance){ | ||
this.name=name; | ||
|
||
if (balance>0.0){ | ||
this.balance = balance; | ||
} | ||
} | ||
|
||
public void deposit(double depositAmt){ | ||
if (depositAmt>0.0){ | ||
balance+=depositAmt; | ||
} | ||
} | ||
|
||
public double getBalance(){ | ||
return balance; | ||
} | ||
|
||
public void setName(String name){ | ||
this.name=name; | ||
} | ||
|
||
public String getName(){ | ||
return name; | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import java.util.Scanner; | ||
|
||
public class AccountTest{ | ||
|
||
public static void main(String[] args) { | ||
|
||
Scanner input = new Scanner(System.in); | ||
Account myAccount = new Account("Stanley Brikkz", 23.44); | ||
System.out.println("Name: " + myAccount.getName()); | ||
System.out.printf("Balance: $%.2f", myAccount.getBalance()); | ||
|
||
System.out.println("Enter Amount To Deposit:"); | ||
double depositAmt = input.nextDouble(); | ||
myAccount.deposit(depositAmt); | ||
System.out.printf("New Balance: $%.2f", myAccount.getBalance()); | ||
} | ||
|
||
} |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import java.io.File; | ||
import java.io.PrintWriter; | ||
import java.io.FileNotFoundException; | ||
import java.util.Scanner; | ||
|
||
public class Account extends Bank | ||
{ | ||
File file = new File("Bank.txt"); | ||
|
||
public Account(String accountName, double balance) | ||
{ | ||
this.accountName = accountName; | ||
this.balance = balance; | ||
} | ||
|
||
public void Deposit(double depositAmount) | ||
{ | ||
|
||
if (depositAmount > 0.0) | ||
{ | ||
balance += depositAmount; | ||
Log("Deposited $"+ depositAmount + " in "+ accountName + "'s account. New balance: $" + getBalance()); | ||
} | ||
} | ||
|
||
public void Withdraw(double withdrawal) | ||
{ | ||
if (withdrawal > balance) | ||
{ | ||
System.out.println("Withdrawal amount exceeded account balance!"); | ||
} | ||
else | ||
{ | ||
balance -= withdrawal; | ||
Log("Withdrew $" + withdrawal + " from " + accountName + "'s account. New balance: $" + balance); | ||
} | ||
} | ||
|
||
public double getBalance() | ||
{ | ||
return balance; | ||
} | ||
|
||
public void Log(String logData) | ||
{ | ||
try | ||
{ | ||
Scanner input = new Scanner(file); | ||
String data = ""; | ||
|
||
while (input.hasNextLine()) | ||
{ | ||
data += input.nextLine() + "\n"; | ||
} | ||
|
||
PrintWriter log = new PrintWriter(file); | ||
log.print(data + logData); | ||
log.close(); | ||
} | ||
catch (FileNotFoundException e) | ||
{ | ||
System.out.println("Error accessing file!"); | ||
} | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import java.util.Scanner; | ||
|
||
public class AccountTest | ||
{ | ||
public static void main(String[] args) | ||
{ | ||
Scanner input = new Scanner(System.in); | ||
String accName; | ||
Double accBalance, amount; | ||
int operation; | ||
|
||
System.out.println("Enter account holder's name:"); | ||
accName = input.nextLine(); | ||
System.out.println("Enter account balance:"); | ||
accBalance = input.nextDouble(); | ||
|
||
Account myAccount = new Account(accName, accBalance); | ||
|
||
System.out.println("Choose Operation:\n1. Deposit\n2. Withdraw\n3. Check Balance"); | ||
operation = input.nextInt(); | ||
|
||
switch (operation) | ||
{ | ||
case 1: | ||
System.out.println("Enter deposit amount:"); | ||
amount = input.nextDouble(); | ||
myAccount.Deposit(amount); | ||
break; | ||
case 2: | ||
System.out.println("Enter withdrawal amount:"); | ||
amount = input.nextDouble(); | ||
myAccount.Withdraw(amount); | ||
break; | ||
case 3: | ||
System.out.println("Account Balance: $" + myAccount.getBalance()); | ||
break; | ||
default: | ||
System.out.println("Invalid option!"); | ||
break; | ||
} | ||
} | ||
} |
Binary file not shown.
Oops, something went wrong.