Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
tarunsinghofficial committed Oct 20, 2021
2 parents 124ab27 + cfff94a commit 47bf856
Show file tree
Hide file tree
Showing 103 changed files with 6,473 additions and 10 deletions.
8 changes: 4 additions & 4 deletions 2048.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ int checkover(int a[4][4])
int main()
{
cout<<"\n\n\n\n\t\t\t2048 GAME\n\n\n\t\tPress any key to continue";
getch();
system("cls");
getch(); // It will take an input from the keyboard.
system("cls"); // It will clear the screen.
int i1,i2,i3,i4,i,j;
int a[4][4]={0},tmp[4][4]={0};
srand(time(0));
Expand All @@ -245,8 +245,8 @@ int main()
int ch;
while (1)
{
for(i=0;i<4;i++)
for(j=0;j<4;j++)
for(i=0;i<4;i++) //Outer for loop.
for(j=0;j<4;j++) //Inner for loop.
tmp[i][j]=a[i][j];
ch=getch();
system("cls");
Expand Down
5 changes: 5 additions & 0 deletions AarushiSingh.md
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
***
35 changes: 35 additions & 0 deletions C Program/insertionSort.c
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);
}
34 changes: 34 additions & 0 deletions C Program/simple_calculator.cpp
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;
}
1 change: 1 addition & 0 deletions Chetan Bogali.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

5 changes: 5 additions & 0 deletions Eshller.md
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
***
5 changes: 5 additions & 0 deletions Faustina_Leonita.md
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
***
4 changes: 4 additions & 0 deletions Hithru.md
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
21 changes: 21 additions & 0 deletions Java Fundamentals programs/ArrayElement.java
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 added Java Fundamentals programs/Assignment 2.zip
Binary file not shown.
57 changes: 57 additions & 0 deletions Java Fundamentals programs/Assignment.java
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");
}
}
}
26 changes: 26 additions & 0 deletions Java Fundamentals programs/BMI.java
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 added Java Fundamentals programs/BankAccount/Account.class
Binary file not shown.
31 changes: 31 additions & 0 deletions Java Fundamentals programs/BankAccount/Account.java
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.
18 changes: 18 additions & 0 deletions Java Fundamentals programs/BankAccount/AccountTest.java
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 added Java Fundamentals programs/BankAccount/X.class
Binary file not shown.
Binary file added Java Fundamentals programs/Banking/Account.class
Binary file not shown.
65 changes: 65 additions & 0 deletions Java Fundamentals programs/Banking/Account.java
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.
42 changes: 42 additions & 0 deletions Java Fundamentals programs/Banking/AccountTest.java
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 added Java Fundamentals programs/Banking/Bank.class
Binary file not shown.
Loading

0 comments on commit 47bf856

Please sign in to comment.