├── Arithmetic using Switch case ├── Automorphic Number ├── Match Details using String ├── Math function ├── Student Grade ├── Vowels └── equals using String /Arithmetic using Switch case: -------------------------------------------------------------------------------- 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 | Scanner sc = new Scanner(System.in); 11 | int a=sc.nextInt(); 12 | int b=sc.nextInt(); 13 | char ch=sc.next().charAt(0); 14 | switch(ch){ 15 | case '+': 16 | System.out.println("Addition of two number is " +((float)a+b)); 17 | break; 18 | case '-': 19 | System.out.println("Subtraction of two number is " +((float)a-b)); 20 | break; 21 | case '*': 22 | System.out.println("Multiplication of two number is " +((float)a*b)); 23 | break; 24 | case '/': 25 | System.out.println("Division of two number is " +((float)a/b)); 26 | break; 27 | case'%': 28 | System.out.println("Modulo of two number is " +((float)a%b)); 29 | break; 30 | default: 31 | System.out.println("Invalid Input"); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Automorphic Number: -------------------------------------------------------------------------------- 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 | Scanner sc = new Scanner(System.in); 11 | int num=sc.nextInt(); 12 | if(num<1||num>9) 13 | { 14 | System.out.println("Invalid Input"); 15 | }else{ 16 | int Square=num*num; 17 | String numStr=Integer.toString(num); 18 | String SquareStr=Integer.toString(Square); 19 | if(SquareStr.endsWith(numStr)){ 20 | System.out.println("Automorphic Number"); 21 | } 22 | else{ 23 | System.out.println("Not Automorphic Number"); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Match Details using String: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | 4 | public class Solution { 5 | 6 | public static void main(String[] args) { 7 | /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ 8 | Scanner s = new Scanner(System.in); 9 | String a = s.nextLine(); 10 | int b = s.nextInt(); 11 | int c = s.nextInt(); 12 | s.nextLine(); 13 | String a1 = s.nextLine(); 14 | int b1 = s.nextInt(); 15 | int c2 = s.nextInt(); 16 | System.out.println("Match Details:"); 17 | System.out.println("Team 1: "); 18 | System.out.println("Name: "+a); 19 | System.out.println("Score: "+b); 20 | System.out.println("Overs played: "+c); 21 | System.out.println("Team 2: "); 22 | System.out.println("Name: "+a1); 23 | System.out.println("Score: "+b1); 24 | System.out.println("Overs played: "+c2); 25 | } 26 | } 27 | 28 | -------------------------------------------------------------------------------- /Math function: -------------------------------------------------------------------------------- 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 | Scanner s = new Scanner(System.in); 11 | float f =s.nextFloat(); 12 | int n1 = s.nextInt(); 13 | int n2 = s.nextInt(); 14 | int n3 = s.nextInt(); 15 | System.out.println((int)Math.floor(f)); 16 | System.out.println((int)Math.ceil(f)); 17 | System.out.println((int)Math.round(f)); 18 | System.out.println((int)Math.sqrt(n1)); 19 | System.out.println((int)Math.pow(n2,n3)); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Student Grade: -------------------------------------------------------------------------------- 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 | Scanner sc=new Scanner(System.in); 11 | String a=sc.nextLine(); 12 | int m1=sc.nextInt(); 13 | int m2=sc.nextInt(); 14 | int m3=sc.nextInt(); 15 | int m4=sc.nextInt(); 16 | int m5=sc.nextInt(); 17 | int tm=m1+m2+m3+m4+m5; 18 | int avg=(int)tm/5; 19 | System.out.println("Name of the Student:"+a); 20 | System.out.println("Total Mark:"+tm); 21 | System.out.println("Average Mark:"+tm/5.0); 22 | int grade; 23 | 24 | if(avg==100){ 25 | System.out.println("Grade Mark:S"); 26 | } 27 | else if(avg>90&&avg<=99){ 28 | System.out.println("Grade Mark:A"); 29 | } 30 | else if(avg>80&&avg<=89){ 31 | System.out.println("Grade Mark:B"); 32 | } 33 | else if(avg>70&&avg<=79){ 34 | System.out.println("Grade Mark:C"); 35 | } 36 | else if(avg>60&&avg<=69){ 37 | System.out.println("Grade Mark:D"); 38 | } 39 | else if(avg>50&&avg<=59){ 40 | System.out.println("Grade Mark:E"); 41 | } 42 | else{ 43 | System.out.println("Grade Mark:Fail"); 44 | } 45 | 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Vowels: -------------------------------------------------------------------------------- 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 | Scanner sc = new Scanner(System.in); 11 | char v = sc.next().charAt(0); 12 | if(v>='a'&&v<='z'||v>='A'&&v<='Z'){ 13 | if(v=='a' ||v=='e' ||v=='i' ||v=='o' ||v=='u' ||v=='A' ||v=='E' ||v=='I' ||v=='O' ||v=='U' ) 14 | { 15 | System.out.println("The Character "+v+" is Vowel"); 16 | } 17 | else 18 | { 19 | System.out.println("The Character "+v+" is Consonant"); 20 | } 21 | } 22 | else 23 | { 24 | System.out.println("Invalid Input"); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /equals using String: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | 4 | public class Solution { 5 | 6 | public static void main(String[] args) { 7 | Scanner sc=new Scanner(System.in); 8 | String a=sc.nextLine(); 9 | if(a.equals("RED")) 10 | { 11 | System.out.println("The Chromatic Horizon reveals: It is Dusk"); 12 | }else if(a.equals("BLUE")){ 13 | System.out.println("The Chromatic Horizon whispers: It is Dawn"); 14 | }else{ 15 | System.out.println("The Chromatic Riddle unfolds: Invalid Input"); 16 | } 17 | /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ 18 | } 19 | } 20 | 21 | --------------------------------------------------------------------------------