Skip to content
Closed
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
22 changes: 22 additions & 0 deletions CheckNumber.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.numbercheck;

import java.util.Scanner;

public class CheckNumber {
public static void main(String[]args) {
//Scanner sc = new Scanner(System.in);
//int n = sc.nextInt();
CheckNumber(-999);
}
public static void CheckNumber(int n) {
//Scanner sc = new Scanner(System.in);
//n = sc.nextInt();
if(n>0) {
System.out.println("Positive");
}else if(n<0) {
System.out.println("Negative");
}else if(n==0) {
System.out.println("zero");
}
}
}
18 changes: 18 additions & 0 deletions EvenOdd.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.evenodd;

import java.util.Scanner;

public class EvenOdd {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter the Number: ");
int n=sc.nextInt();
if (n%2==0)
System.out.println("Number is EVEN");

else
System.out.println("number is ODD");

}

}
15 changes: 15 additions & 0 deletions Method.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.method;

public class Method {
public static void main (String[]args) {
calculateScore(true,800,5,100);
calculateScore(true,1000,8,200);
}
public static void calculateScore(boolean gameover,int score,int levelCompleted,int bonus) {
if(gameover) {
int finalScore = score + (levelCompleted * bonus);
finalScore += 2000;
System.out.println("Your Final Score was"+ finalScore);
}
}
}
27 changes: 27 additions & 0 deletions Palindrome.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.palindrome;

import java.util.Scanner;

public class Palindrome {
public static void main (String[]args) {
Scanner sc = new Scanner(System.in);
int n,sum=0,rem;
System.out.println("Enter a number: ");
n=sc.nextInt();
int temp=n;
while(n>0) {
rem=n % 10;
sum=(sum*10)+rem;
n=n / 10;
}
if(temp==sum)
{
System.out.println("Number is Palindrome");
}
else
{
System.out.println("Number is not Plaindrome");
}

}
}
36 changes: 36 additions & 0 deletions Prime.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.Prime;

public class Prime {

public static void main(String[] args) {
// TODO Auto-generated method stub
java.util.Scanner sc=new java.util.Scanner(System.in);
System.out.println("enter number");

int n,flag=0;
n=sc.nextInt();
if(n==1 || n==0)
{
System.out.println("Prime starts from 2");
}
else
{
for(int i=2;i<n ;i++)
{
if(n%i==0)
{
System.out.println("not a prime");
flag=1;
break;
}
}
if(flag==0)
{

System.out.println("prime");

}
}
}

}
30 changes: 30 additions & 0 deletions ReverseNumber.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.Reverse;

import java.util.Scanner;

public class ReverseNumber {
public static void main(String[] args) {
System.out.println("Please enter number to be reversed: ");
Scanner sc= new Scanner(System.in);
int number =sc.nextInt();

int sum = reverse(number);
System.out.println("Reverse of number: " + number + " is " + reverse(number));
}
public static int reverse(int number){
int sum = 0;
int remainder;
do{
remainder = number%10;
sum = sum*10 + remainder;
number = number/10;

}while(number > 0);

return sum;
}

}



22 changes: 22 additions & 0 deletions StringReverse.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import java.util.Scanner;

public class StringReverse {

public static void main(String[] args) {
// TODO Auto-generated method stub

//String st = "JAVA DEMO";
System.out.print("Enter string to reverse:");
Scanner read = new Scanner(System.in);
String str = read.nextLine();
String reverse= "";

for(int i= str.length()-1; i>=0; i--) {
reverse = reverse + str.charAt(i);
}


System.out.println("Reversed String is:" + reverse +".");
}

}
16 changes: 16 additions & 0 deletions Timecalculation.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.time;

public class Timecalculation {
public static void main(String[]args) {
System.out.println(Calculation(23,56));
}
public static String Calculation(long minutes,long seconds) {
if(minutes<0 || seconds<0 || seconds>59) {
return "Invalid value";
}
long hours = minutes/60;
long remMinutes = minutes % 60;
return hours + "h" + remMinutes + "m" + seconds + "s";
}

}
26 changes: 26 additions & 0 deletions Triangle.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.triangle;

import java.util.Scanner;

public class Triangle {

public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
System.out.println("enter the number");
int n = sc.nextInt();
for(int i=0;i<n ;i++)
{
for (int j=0;j<n-i-1;j++)
{
System.out.print(" ");
}
for(int k=0;k<=i; k++)
{
System.out.print("* ");
}
System.out.println( );
}
}

}
30 changes: 30 additions & 0 deletions fibanocci.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.fabinoccii;

import java.util.Scanner;

public class fibanocci {

public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc= new Scanner(System.in);
System.out.println("ENTER NUMBER");
int n=sc.nextInt();
int a=0;
int b=1;
int c=0;
System.out.print(a);
System.out.print(b);
for (int i = 2; i <=n; i++)
{
c=a + b;
if(c<=n)
{
//c=a + b;
System.out.print(c);
a=b;
b=c;
}
}

}
}
16 changes: 16 additions & 0 deletions square.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.evenodd;

import java.util.Scanner;

public class EvenOdd {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter the Number: ");
int n=sc.nextInt();
n = n * n;
System.out.println(n);


}

}