Skip to content

Commit 87d11fa

Browse files
main
1 parent 6896479 commit 87d11fa

19 files changed

+738
-4
lines changed

.vscode/settings.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
{
22
"java.project.sourcePaths": [
3-
"3.Array/ClassCodes",
4-
"3.Array",
5-
"2.Loop",
63
"1.DataType",
7-
"4.Operators/ClassCodes"
4+
"2.Loop",
5+
"3.Array",
6+
"3.Array\\ClassCodes",
7+
"4.Operators\\ClassCodes",
8+
"5.ControlStatement\\ifElse\\ClassCodes",
9+
"5.ControlStatement\\ifElse\\Assignments"
810
]
911
}

4.Operators/ClassCodes/Program15.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
public class Program15 {
2+
public static void main(String[] args) {
3+
4+
int x = 7;
5+
6+
System.out.println(x >> 2);
7+
System.out.println(x >>> 2);
8+
}
9+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
2+
3+
/*
4+
Program 1: Write a java program to check if a number is even or odd.
5+
6+
Input: var=10;
7+
Output: 10 is an even no
8+
Input: var=37;
9+
Output: 37 is an odd no
10+
Input : var = 0
11+
Output: ???
12+
*/
13+
14+
package Assignment01;
15+
16+
import java.io.BufferedReader;
17+
import java.io.InputStreamReader;
18+
19+
public class program1 {
20+
public static void main(String[] args)throws Exception {
21+
22+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
23+
24+
System.out.println("Enter the number: ");
25+
int num = Integer.parseInt(br.readLine());
26+
27+
if(num % 2==1){
28+
System.out.println(num+" is an odd no.");
29+
}
30+
31+
else{
32+
System.out.println(num+" is an even no.");
33+
}
34+
35+
}
36+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package Assignment01;
2+
3+
import java.io.BufferedReader;
4+
import java.io.InputStreamReader;
5+
6+
public class program10 {
7+
public static void main(String[] args)throws Exception {
8+
9+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
10+
11+
System.out.println("Enter the Moner: ");
12+
float money = Float.parseFloat(br.readLine());
13+
14+
15+
if (money <= 0.00f) {
16+
System.out.println("Don't Go Anywhere keep starving");
17+
}
18+
else if (money >= 700.00f) {
19+
System.out.println("party at Barbeque Nation");
20+
}
21+
else if (money >= 5000.00f) {
22+
System.out.println("Dine in 5 star");
23+
}
24+
else {
25+
System.out.println("monthly mess");
26+
}
27+
}
28+
29+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
2+
/*
3+
4+
Program 2: Write a java program, take a number, and print whether it is less than 10 or
5+
greater than 10.
6+
7+
Input1: var=5
8+
Output: 5 Is Less than 10.
9+
Input2: var=16
10+
Output: 16 Is greater than 10.
11+
Input3 : var=10
12+
Output: ??
13+
14+
*/
15+
16+
17+
package Assignment01;
18+
19+
import java.io.BufferedReader;
20+
import java.io.InputStreamReader;
21+
22+
public class program2 {
23+
public static void main(String[] args)throws Exception {
24+
25+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
26+
27+
System.out.println("Enter the number: ");
28+
int num = Integer.parseInt(br.readLine());
29+
30+
if(num>10){
31+
32+
System.out.println(num+" is greater than 10.");
33+
}
34+
35+
else if(num==10){
36+
37+
System.out.println(num+" is equal to 10.");
38+
}
39+
40+
else{
41+
System.out.println(num+" is less than 10.");
42+
}
43+
44+
45+
46+
}
47+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
2+
3+
/*
4+
Program 3: Write a java program, take a number, and print whether it is positive or
5+
negative.
6+
7+
Input: num = 5
8+
Output: 5 is a positive number
9+
Input: num = -9
10+
Output: -9 is a negative number
11+
Input: num = 0
12+
Output: ???????
13+
14+
15+
*/
16+
17+
18+
package Assignment01;
19+
20+
import java.io.BufferedReader;
21+
import java.io.InputStreamReader;
22+
23+
public class program3 {
24+
25+
public static void main(String[] args)throws Exception {
26+
27+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
28+
29+
System.out.println("Enter the number: ");
30+
int num = Integer.parseInt(br.readLine());
31+
32+
if(num < 0){
33+
34+
System.out.println(num+" is negative number.");
35+
}
36+
else if(num==0){
37+
38+
System.out.println(num+" is neither positive nor negative.");
39+
}
40+
41+
else{
42+
System.out.println(num+" it is negative number.");
43+
}
44+
45+
}
46+
47+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
3+
Program 4: Write a java program that checks a number from 0 to 5 and prints its
4+
spelling, if the number is greater than 5 print the number is greater than 5
5+
Input1 : var= 4
6+
Output: four
7+
Input2 : var = 6
8+
Output: number is greater than 5
9+
Input3 : var = -6
10+
Output: ???
11+
12+
*/
13+
14+
15+
package Assignment01;
16+
17+
import java.io.BufferedReader;
18+
import java.io.InputStreamReader;
19+
20+
public class program4 {
21+
22+
public static void main(String[] args)throws Exception {
23+
24+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
25+
26+
System.out.println("Enter the number: ");
27+
int num = Integer.parseInt(br.readLine());
28+
29+
if(num==0){
30+
System.out.println("zero");
31+
}
32+
33+
else if(num==1){
34+
System.out.println("One");
35+
}
36+
else if(num==2){
37+
System.out.println("Two");
38+
}
39+
else if(num==3){
40+
System.out.println("Three");
41+
}
42+
else if(num==4){
43+
System.out.println("Four");
44+
}
45+
46+
else if(num==5){
47+
System.out.println("Five");
48+
}
49+
50+
else if(num > 5){
51+
System.out.println(num+" is greater than 5.");
52+
}
53+
54+
else{
55+
System.out.println(num+" is negative number.");
56+
}
57+
}
58+
59+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
2+
/*
3+
Program 5: Write a java program, in which according to month no print the no. of
4+
days in that month
5+
Input : month = 7
6+
Output: July has 31 days
7+
Input : month = 13
8+
Output: Invalid month
9+
Input : month = -6
10+
Output: ???
11+
*/
12+
13+
package Assignment01;
14+
import java.io.BufferedReader;
15+
import java.io.InputStreamReader;
16+
17+
public class program5 {
18+
19+
public static void main(String[] args)throws Exception {
20+
21+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
22+
23+
System.out.println("Enter the number: ");
24+
int month = Integer.parseInt(br.readLine());
25+
26+
if(month==1){
27+
System.out.println("January has 31 days.");
28+
}
29+
else if(month==2){
30+
System.out.println("February has 28 days. ");
31+
}
32+
else if(month==3){
33+
System.out.println("March has 31 days. ");
34+
}
35+
else if(month==4){
36+
System.out.println("April has 30 days. ");
37+
}
38+
else if(month==5){
39+
System.out.println("May has 31 days. ");
40+
}
41+
else if(month==6){
42+
System.out.println("Jun has 30 days. ");
43+
}
44+
else if(month==7){
45+
System.out.println("July has 31 days. ");
46+
}
47+
else if(month==8){
48+
System.out.println("August has 31 days. ");
49+
}
50+
else if(month==9){
51+
System.out.println("September has 30 days. ");
52+
}
53+
else if(month==10){
54+
System.out.println("Auctober has 31 days. ");
55+
}
56+
else if(month==11){
57+
System.out.println("November has 30 days. ");
58+
}
59+
else if(month==12){
60+
System.out.println("December has 31 days. ");
61+
}
62+
63+
else{
64+
System.out.println("Invalid input...!");
65+
}
66+
67+
}
68+
69+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
2+
/*
3+
4+
Program 6: write a program to find a maximum between three numbers
5+
inputs1 :
6+
num1 = 1
7+
num2 = 2
8+
num3 = 3
9+
Output: 3 is the maximum between 1, 2 and 3
10+
inputs2 :
11+
num1 = 1
12+
num2 = 4
13+
num3 = 3
14+
Output: 4 is the maximum between 1, 4 and 3
15+
16+
inputs3 :
17+
num1 = 42
18+
num2 = 32
19+
num3 = 42
20+
Output: ?????
21+
22+
*/
23+
24+
package Assignment01;
25+
26+
import java.io.BufferedReader;
27+
import java.io.InputStreamReader;
28+
29+
public class program6 {
30+
31+
public static void main(String[] args)throws Exception {
32+
33+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
34+
35+
System.out.println("Enter the number1: ");
36+
int num1 = Integer.parseInt(br.readLine());
37+
38+
System.out.println("Enter the number2: ");
39+
int num2 = Integer.parseInt(br.readLine());
40+
41+
System.out.println("Enter the number3: ");
42+
int num3 = Integer.parseInt(br.readLine());
43+
44+
if(num1 >num2 && num1 > num3){
45+
System.out.println(num1+" is greater.");
46+
}
47+
48+
else if(num2 >num1 && num2 >num3){
49+
System.out.println(num1+" is greater.");
50+
51+
}
52+
else if(num3 >num1 && num3 >num2){
53+
System.out.println(num3+" is greater.");
54+
55+
}
56+
else if(num2==num1 && num2 > num3){
57+
System.out.println(num1+"and "+num2+" are equal");
58+
59+
}
60+
61+
else if(num2==num3 && num1 < num3){
62+
System.out.println(num2+"and "+num3+" are equal");
63+
64+
}
65+
66+
else if(num1==num3 && num2 < num3){
67+
System.out.println(num1+"and "+num3+" are equal");
68+
69+
}
70+
71+
else{
72+
System.out.println("All are equal.");
73+
}
74+
75+
}
76+
77+
}

0 commit comments

Comments
 (0)