0% found this document useful (0 votes)
2 views

javaDay1

The document contains a Java program that demonstrates various control structures including if-else statements, switch-case statements, and for loops. It performs operations such as printing greetings based on the value of 'n', generating a multiplication table, and calculating the sum of integers, squares, and cubes up to a specified number. The program also includes output statements to display the results of these calculations.

Uploaded by

xnoscope1x
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

javaDay1

The document contains a Java program that demonstrates various control structures including if-else statements, switch-case statements, and for loops. It performs operations such as printing greetings based on the value of 'n', generating a multiplication table, and calculating the sum of integers, squares, and cubes up to a specified number. The program also includes output statements to display the results of these calculations.

Uploaded by

xnoscope1x
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

// Online Java Compiler

// Use this editor to write, compile and run your Java code online

class Main {
public static void main(String[] args) {

int n = 9;
if(n == 1){
System.out.println("Namaste");
}
else if(n == 2){
System.out.println("Hello");
}
else{
System.out.println("Bonjour");
}

switch(n){
case 1:
System.out.println("Namaste");
break;
case 2:
System.out.println("Hello");
break;
case 3:
System.out.println("Bonjour");
break;
default:
System.out.println("Fuck You............");

}
int n =445;
for(int i =1;i<11;i++){
System.out.println(n + "x" + i + "===" + n*i);
}

for(int i = 0; i < 3; i++){


System.out.println("***********");
}

int n = 20;
int sum = 0;
int sum2 = 0;
int sum3 = 0;

for(int i =0;i<n;i++){
sum = sum+i;
System.out.println(sum);
sum2 = sum2+i*i;
System.out.println(sum2);
sum3= sum3+ i*i*i;
System.out.println(sum3);
}

System.out.println(sum);
System.out.println(sum2);
System.out.println(sum3);
}
}

You might also like