├── code1.java ├── code10.java ├── code11.java ├── code12.java ├── code13.java ├── code14.java ├── code15.java ├── code16.java ├── code17.java ├── code2.java ├── code3.java ├── code4.java ├── code5.java ├── code6.java ├── code7.java ├── code8.java └── code9.java /code1.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | class joh { 3 | public static void main(String args[]){ 4 | Scanner john=new Scanner(System.in); 5 | String name=john.nextLine(); 6 | int age=john.nextInt(); 7 | System.out.print(name+" "+age); 8 | 9 | 10 | 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /code10.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | public class solution{ 3 | public static void main(String args[]){ 4 | Scanner sc=new Scanner(System.in); 5 | String s=sc.nextLine(); 6 | char c=sc.nextLine().charAt(0); 7 | for(char ch : s.toCharArray()){ 8 | if(ch==c){ 9 | break; 10 | } 11 | else if(ch!=c){ 12 | System.out.print(ch); 13 | } 14 | } 15 | } 16 | } 17 | -------------------------------------------------- 18 | import java.util.*; 19 | public class solution{ 20 | public static void main(String args[]){ 21 | Scanner sc=new Scanner(System.in); 22 | String s=sc.nextLine(); 23 | char c=sc.nextLine().charAt(0); 24 | for(int i=0;i= 'A' && ch <= 'Z') { 24 | count++; 25 | } 26 | } 27 | System.out.print(count); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /code12.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | 3 | public class Hello { 4 | 5 | public static void main(String[] args) { 6 | // Input scanner 7 | Scanner sc = new Scanner(System.in); 8 | String s = sc.nextLine(); 9 | 10 | // Create a list to hold each character of the string as a String element 11 | List si = new ArrayList<>(); 12 | 13 | // Convert each character of the string to a String and add to list 14 | for (char ch : s.toCharArray()) { 15 | si.add(Character.toString(ch)); // Convert char to String 16 | } 17 | 18 | // Check if the list has more than 1 element before removing 19 | si.remove(0); 20 | si.remove(si.size()-1); 21 | 22 | // Print remaining elements in the list 23 | for (int i = 0; i < si.size(); i++) { 24 | System.out.print(si.get(i)); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /code13.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | public class Hello { 3 | 4 | public static void main(String[] args) { 5 | //Your Code Here 6 | Scanner sc=new Scanner(System.in); 7 | int x=sc.nextInt(); 8 | int y=sc.nextInt(); 9 | while(y!=0){ 10 | int temp=y; 11 | y=x%y; 12 | x=temp; 13 | 14 | } 15 | System.out.print(x); 16 | 17 | 18 | 19 | 20 | 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /code14.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | public class Hello { 3 | 4 | public static void main(String[] args) { 5 | //Your Code Here 6 | Scanner sc=new Scanner(System.in); 7 | String s=sc.nextLine(); 8 | List reverse=new ArrayList<>(); 9 | for(int i=s.length()-1;i>=0;i--){ 10 | reverse.add(Character.toString(s.charAt(i))); 11 | 12 | } 13 | System.out.print(String.join("",reverse)); 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /code15.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | import java.text.*; 4 | import java.math.*; 5 | import java.util.regex.*; 6 | 7 | public class Solution { 8 | 9 | public static void main(String[] args) { 10 | /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ 11 | Scanner sc =new Scanner(System.in); 12 | int linenumber=1; 13 | while(sc.hasNextLine()){ 14 | String Line=sc.nextLine(); 15 | System.out.println(linenumber+" "+Line); 16 | linenumber++; 17 | 18 | } 19 | 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /code16.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | 3 | public class code { 4 | public static void main(String[] args) { 5 | Scanner sc =new Scanner(System.in); 6 | int n=sc.nextInt(); 7 | int m=getreverse(n,0); 8 | if(n==m){ 9 | System.out.print("palindrome"); 10 | } 11 | else{ 12 | System.out.println("not palin"); 13 | } 14 | 15 | 16 | } 17 | static int getreverse(int n,int rev){ 18 | 19 | 20 | if(n==0){ 21 | return rev; 22 | } 23 | int rem=n%10; 24 | rev=rev*10+rem; 25 | n/=10; 26 | return getreverse(n,rev); 27 | 28 | 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /code17.java: -------------------------------------------------------------------------------- 1 | 2 | import java.util.Scanner; 3 | 4 | public class code { 5 | public static void main(String[] args) { 6 | Scanner sc =new Scanner(System.in); 7 | int num=sc.nextInt(); 8 | int length=order(num); 9 | if(isarmstrong(num,length)){ 10 | System.out.println("arm"); 11 | 12 | } 13 | else{ 14 | System.out.println("not arm"); 15 | } 16 | 17 | 18 | } 19 | static int order(int n){ 20 | int i=0; 21 | while(n!=0){ 22 | i++; 23 | n/=10; 24 | } 25 | return i; 26 | 27 | } 28 | static boolean isarmstrong(int n,int m){ 29 | int temp=n; 30 | int sum=0; 31 | while(temp!=0){ 32 | int rem=temp%10; 33 | sum = sum +(int)Math.pow(rem,m); 34 | temp/=10; 35 | 36 | } 37 | return n==sum; 38 | } 39 | } 40 | //code2 41 | 42 | import java.util.Scanner; 43 | 44 | public class code { 45 | public static void main(String[] args) { 46 | Scanner sc =new Scanner(System.in); 47 | int num=sc.nextInt(); 48 | int length=order(num); 49 | if(isarmstrong(num,length)==num){ 50 | System.out.println("arm"); 51 | 52 | } 53 | else{ 54 | System.out.println("not arm"); 55 | } 56 | 57 | 58 | } 59 | static int order(int n){ 60 | int i=0; 61 | while(n!=0){ 62 | i++; 63 | n/=10; 64 | } 65 | return i; 66 | 67 | } 68 | static int isarmstrong(int n,int m){ 69 | if(n==0){ 70 | return 0; 71 | } 72 | int digit=0; 73 | digit=n%10; 74 | return (int)Math.pow(digit,m)+isarmstrong(n/10,m); 75 | } 76 | } 77 | 78 | -------------------------------------------------------------------------------- /code2.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | class joh { 3 | public static void main(String args[]){ 4 | Scanner john=new Scanner(System.in); 5 | String name=john.nextLine(); 6 | int score=john.nextInt(); 7 | john.nextLine(); 8 | String dept=john.nextLine(); 9 | float e=(float)score/10; 10 | System.out.print(e); 11 | 12 | 13 | 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /code3.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | 3 | class joh{ 4 | public static void main(String[] args) { 5 | Scanner scan=new Scanner(System.in); 6 | int num1 =scan.nextInt(); 7 | int num2 =scan.nextInt(); 8 | int temp; 9 | while(num2!=0){ 10 | temp = num2; 11 | num2=num1 % num2; 12 | num1 =temp; 13 | } 14 | System.out.println(a); 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /code4.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | public class Amstrong_no { 3 | public static void main(String[] args) { 4 | Scanner scanner = new Scanner(System.in); 5 | int number = scanner.nextInt(); 6 | int sum = 0; 7 | int temp = number; 8 | 9 | while (temp != 0) { 10 | int digit = temp % 10; 11 | sum += digit * digit * digit; 12 | temp /= 10; 13 | } 14 | 15 | if (sum == number) { 16 | System.out.println(number + " is an Armstrong number."); 17 | } else { 18 | System.out.println(number + " is not an Armstrong number."); 19 | } 20 | 21 | scanner.close(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /code5.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | 3 | class ReverseNumber { 4 | public static void main(String[] args) { 5 | Scanner scan = new Scanner(System.in); 6 | System.out.print("Enter a number: "); 7 | int number = scan.nextInt(); 8 | int reversed = 0; 9 | 10 | // Loop to reverse the number 11 | while (number != 0) { 12 | int digit = number % 10; // Get the last digit 13 | reversed = reversed * 10 + digit; // Append digit to reversed number 14 | number /= 10; // Remove the last digit 15 | } 16 | 17 | System.out.println("Reversed Number: " + reversed); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /code6.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | class joh{ 3 | public static void main(String args[]){ 4 | Scanner scan=new Scanner(System.in); 5 | int num1=scan.nextInt(); 6 | int num2=scan.nextInt(); 7 | num1=num1+num2; 8 | num2=num1-num2; 9 | num1=num1 -num2; 10 | System.out.println(num1); 11 | System.out.println(num2); 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /code7.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | class joh{ 3 | public static void main(String args[]){ 4 | int a=89; 5 | 6 | String y=Integer.toBinaryString(a); 7 | int n=y.length(); 8 | if(y.charAt(n-1)=='0'){ 9 | System.out.print("even");} 10 | else{ 11 | System.out.print("odd"); 12 | } 13 | 14 | 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /code8.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | public class primenumber{ 3 | public static void main(String args[]){ 4 | Scanner sc=new Scanner (System.in); 5 | int n=sc.nextInt(); 6 | int flag=0; 7 | for(int i=2;i<=n/2;i++){ 8 | if(n%i==0){ 9 | flag=1; 10 | break; 11 | } 12 | else{ 13 | continue; 14 | } 15 | } 16 | if(flag==0){ 17 | System.out.print("prime"); 18 | } 19 | else if(flag==1) 20 | { 21 | System.out.print("not prime"); 22 | }}} 23 | -------------------------------------------------------------------------------- /code9.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | public class fibbo{ 3 | public static void main(String args[]){ 4 | Scanner sc=new Scanner(System.in); 5 | int n=sc.nextInt(); 6 | List fib=new ArrayList<>(); 7 | fib.add(0L); 8 | fib.add(1L); 9 | for(int i=2;i