Document
Document
1.
java
import java.util.Scanner;
int a = scanner.nextInt();
int b = scanner.nextInt();
int c = scanner.nextInt();
} else {
System.out.println(a + " is not a common divisor of " + b + " and " + c);
scanner.close();
}
2-
import java.util.Scanner;
} else {
System.exit(0);
scanner.close();
}
3.
java
import java.util.Scanner;
System.out.println("Movie Categories:");
switch (code) {
case 'A':
System.out.println("Adventure movies");
break;
case 'C':
System.out.println("Comedy movies");
break;
case 'F':
System.out.println("Family movies");
break;
case 'H':
System.out.println("Horror movies");
break;
case 'S':
break;
default:
System.out.println("Invalid code");
scanner.close();
4.
java
import java.util.Scanner;
double incomeTax = 0;
// Calculate income tax based on salary
scanner.close();
5.
java
}
}
6.
java
int sum = 0;
System.out.println("____________");
System.out.println("num sum");
sum += num;
System.out.println(num);
num += i + 1;
7.
java
if (args.length != 10) {
return;
int sum = 0;
largest = number;
smallest = number;
sum += number;
8.
java
int sum = 0;
int factorial = 1;
factorial *= j;
sum += factorial;
9.
java
System.out.print(j);
System.out.println();
10.
java
import java.util.Scanner;
scanner.close();
System.out.print((char) alphabet);
alphabet++;
}
System.out.println();
11.
java
int n = 9;
System.out.print("&");
System.out.print(" ");
System.out.print("&");
System.out.println();
In this program, we use a loop to iterate over the rows of the pattern. The variable n represents the
number of rows in the pattern, which is set to 9 in this example.
Inside the loop, we have three nested loops.
The first loop (`j`) is responsible for printing the & symbol n - i times, where n is the total number of
rows and i is the current row number.
The second loop (`k`) is responsible for printing the spaces between the & symbols. The number of
spaces is calculated as 2 * i - 1, where i represents the current row number.
The third loop (`j`) is similar to the first loop and is responsible for printing the & symbol n - i times
again.