├── Pattern └── calculator sum /Pattern: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | public class Main 3 | { 4 | public static void main(String[] args) { 5 | Scanner sc=new Scanner(System.in); 6 | int n=sc.nextInt(); 7 | for(int i=1;i<=n;i++) 8 | { 9 | for(int j=1;j<=n;j++) 10 | { 11 | if(i+j>n){ 12 | System.out.print("* "); 13 | } 14 | else{ 15 | System.out.print(" "); 16 | } 17 | } 18 | System.out.println(); 19 | 20 | } 21 | for(int i=n;i>=1;i--) 22 | { 23 | for(int j=1;j<=n;j++) 24 | { 25 | if(i+j>n){ 26 | System.out.print("* "); 27 | } 28 | else{ 29 | System.out.print(" "); 30 | } 31 | } 32 | System.out.println(); 33 | 34 | } 35 | 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /calculator sum: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | import java.lang.Math; 3 | public class Main{ 4 | public static void main(String[]args){ 5 | Scanner sc=new Scanner(System.in); 6 | boolean boon=true; 7 | while(boon){ 8 | System.out.print("Enter the value of a:"); 9 | int a=sc.nextInt(); 10 | System.out.print("Enter the value of b:"); 11 | int b=sc.nextInt(); 12 | 13 | System.out.println("1.Addition\n2.Subtraction\n3.Multiplication\n4.Division\n5.Modulus\n6.Square root\n7.Cube root\n8.Power"); 14 | System.out.print("Enter your choice:"); 15 | int n=sc.nextInt(); 16 | 17 | 18 | switch(n) 19 | { 20 | case 1: 21 | System.out.println(a+b); 22 | break; 23 | case 2: 24 | System.out.println(a-b); 25 | break; 26 | case 3: 27 | System.out.println(a*b); 28 | break; 29 | case 4: 30 | System.out.println(a/b); 31 | break; 32 | case 5: 33 | System.out.println(a%b); 34 | break; 35 | case 6: 36 | System.out.println(Math.sqrt(a)); 37 | System.out.println(Math.sqrt(b)); 38 | case 7: 39 | System.out.println(Math.cbrt(a)); 40 | System.out.println(Math.cbrt(b)); 41 | case 8: 42 | System.out.println(Math.pow(a,b)); 43 | break; 44 | } 45 | System.out.println("Do you want to continue?? 0 or 1"); 46 | int x=sc.nextInt(); 47 | if(x==0){ 48 | boon=false; 49 | } 50 | else{ 51 | boon=true; 52 | } 53 | } 54 | } 55 | } 56 | --------------------------------------------------------------------------------