0% found this document useful (0 votes)
14 views4 pages

Java Codes

The document contains commented-out Java code snippets demonstrating various programming concepts such as input/output, arithmetic operations, conditional statements, loops, and nested loops. It includes examples for taking user input, performing calculations, and printing patterns. The code is structured within a main method of a class named 'FirstClass'.

Uploaded by

anshsriv.2001
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views4 pages

Java Codes

The document contains commented-out Java code snippets demonstrating various programming concepts such as input/output, arithmetic operations, conditional statements, loops, and nested loops. It includes examples for taking user input, performing calculations, and printing patterns. The code is structured within a main method of a class named 'FirstClass'.

Uploaded by

anshsriv.2001
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

import java.util.

*;

class FirstClass{
public static void main(String[] args) {
//output
// System.out.println("I LOVE YOU ADII");
// System.out.print("AAP BEST HO JII\nI MISS YOU JII\n");
// System.out.println("I LOVE YOU ADII");
// System.out.println("*\n**\n***\n****");
//int a = 10;
//int b = 5;

// int ans =(a*b)/ (a-b);


// System.out.println(ans);
//input
//Scanner sc = new Scanner(System.in);
// String name = sc.nextLine();
// System.out.println(name);

// To take integer as an input


// Scanner sc =new Scanner(System.in);
// int c = sc.nextInt();
// int d = sc.nextInt();
// int ans = (c+d)*(c-d);
// System.out.println(ans);

// Scanner sc =new Scanner(System.in);


// int a = sc.nextInt();
// int b = a * 1;
// int c =a*2;
// int d =a*3;
// int e=a*4;
//int f =a*5;
// int g =a*6;
// int h =a*7;
// int i=a*8;
// int j=a*9;
// int k=a*10;

// System.out.println(c);
// System.out.println(d);
// System.out.println(e);
// System.out.println(f);
// System.out.println(g);
// System.out.println(h);
// System.out.println(i);
// System.out.println(j);
// System.out.println(k);

// Conditional statement( IF ELSE )

// Scanner sc = new Scanner(System.in);


// int age = sc.nextInt();

// if(age > 18){


// System.out.println("ADULT");
// } else{
// System.out.println(" NOT ADULT");
// }
//Scanner sc = new Scanner(System.in);
// int x = sc.nextInt();

// if(x%2 ==1){
// System.out.println("odd");
// }else{
// System.out.println("even");
// }
// int y = x%4;
// System.out.println(y);
//Scanner sc = new Scanner(System.in);
// int x = sc.nextInt();
// int y = sc.nextInt();
//if(x==y){
//System.out.println("EQUAL");
//}
//else if(x>y){
//System.out.println("x is greater than y");
///} else{
// System.out.println("x is less than y");
//}

//Scanner sc = new Scanner(System.in);


//int button = sc.nextInt();

//if(button ==1){
// System.out.println("HELLO");
//}else if (button ==2){
// System.out.println("NAMASTE");
//}else if(button ==3){
// System.out.println("RAM RAM BHAIYA");
//}else{
//System.out.println("ERROR");
//}

// MONTH NUMSER SE MONTH KA NAM


//switch(button) {
// case 1 : System.out.println("JANUARY");
// break;
// case 2 : System.out.println("FEBRUARY");
// break;
// case 3 : System.out.println("MARCH");
// break;
// case 4:System.out.println("APRIL");
// break;
// case 5:System.out.println("MAY");
// break;
// case 6:System.out.println("JUNE");
// break;
// case 7 :System.out.println("JULY");
// break;
// case 8:System.out.println("AUGUST");
//break;
//case 9:System.out.println("SEPTEMBER");
//break;
//case 10:System.out.println("OCTOBER");
//break;
//case 11:System.out.println("NOVEMBER");
//break;
//case 12:System.out.println("DECEMBER");
//break;
//default : System.out.println("ERROR");
//}

//LOOPS

//for(int counter =1; counter<100;counter = counter+1){


// System.out.println("I LOVE YOU ADII");
//}
// (x++ => x=x+1)
//for(
//int x =1 ; x < 11 ; x++){
// System.out.print(x);

// while(condition)
//int x =0;
// while(x<11){
// System.out.println(x);
// x++;
// }

// do while condition
// do{
// System.out.println(x);
// x++;
// }while(x<11);
//Scanner sc = new Scanner(System.in);
//int n = sc.nextInt();
// int sum =0;
// for(int i=0;i <= n;i++){
// sum=sum+i;
// }
// System.out.println(sum);

// table of 2 via for


//for(int i=2;i<11;i++){

//System.out.println(n*i);
//}

// NESTED LOOPS

// Scanner sc = new Scanner(System.in);


// int n= sc.nextInt();
// int m = sc.nextInt();

// //OUTER LOOP
// for(int i=1; i<=n ;i++){
// // INNER LOOP
// for(int j=1; j<=m;j++){
// System.out.print("*");
// }System.out.println();
// }
// Scanner sc = new Scanner(System.in);
// int n= sc.nextInt();
// int m = sc.nextInt();
// int y = n / m;
// System.out.println(y);

// PRINTING THE PATTERNS

}
}

You might also like