File tree Expand file tree Collapse file tree 15 files changed +278
-0
lines changed
B-Control Flow-Conditionals Expand file tree Collapse file tree 15 files changed +278
-0
lines changed Original file line number Diff line number Diff line change
1
+ import java.util.Scanner;
2
+ public class Solution
3
+ {
4
+ public static void main(String[] args) {
5
+ // take input
6
+ // write your logic ...
7
+ Scanner sc = new Scanner(System.in);
8
+ int a=sc.nextInt();
9
+ int b=sc.nextInt();
10
+ int c=sc.nextInt();
11
+ int total=a+b+c;
12
+ int avg=total/3;
13
+ System.out.println(avg);
14
+ }
15
+ }
Original file line number Diff line number Diff line change
1
+ import java.util.Scanner;
2
+ public class Solution
3
+ {
4
+ public static void main(String[] args) {
5
+ Scanner sc = new Scanner(System.in);
6
+ int a=sc.nextInt();
7
+ int b=sc.nextInt();
8
+ long res = (long)a*b;
9
+ System.out.println(res);
10
+
11
+ }
12
+ }
Original file line number Diff line number Diff line change
1
+ import java.util.Scanner;
2
+
3
+ public class Main {
4
+
5
+
6
+ public static void main(String[] args) {
7
+ /* Your class should be named Main.
8
+ * Read input as specified in the question.
9
+ * Print output as specified in the question.
10
+ */
11
+ Scanner sc=new Scanner(System.in);
12
+ int x1=sc.nextInt();
13
+ int y1=sc.nextInt();
14
+ int x2=sc.nextInt();
15
+ int y2=sc.nextInt();
16
+ int area=Math.abs(x1-x2) * Math.abs(y1-y2);
17
+ System.out.println(area);
18
+
19
+ // Write your code here
20
+
21
+ }
22
+
23
+ }
Original file line number Diff line number Diff line change
1
+ import java.util.* ;
2
+ import java.io.*;
3
+ class Solution {
4
+
5
+ public static void main(String args[]) {
6
+ Scanner sc = new Scanner(System.in);
7
+ // Write code here
8
+ int p=sc.nextInt();
9
+ double r=sc.nextDouble();
10
+ int t=sc.nextInt();
11
+ double interest=(p*t*r)/100;
12
+ System.out.println((int)interes);
13
+
14
+ }
15
+ }
Original file line number Diff line number Diff line change
1
+ public class Solution {
2
+ public static void main(String[] args) {
3
+ int a = 12; // value for 'a'
4
+ int b = 7; // value for 'b'
5
+
6
+
7
+ // Bitwise left shift for 'a'
8
+ System.out.println(a<<1);
9
+ System.out.println(b>>1);
10
+
11
+ // Bitwise right shift for 'b'
12
+
13
+ }
14
+ }
Original file line number Diff line number Diff line change
1
+ public class Solution {
2
+ public static void main(String[] args) {
3
+ double doubleValue = 9.85; // Initial double value
4
+
5
+ // Type casting from double to int
6
+ int result = (int) doubleValue;
7
+ System.out.println(result);
8
+ // Print the result
9
+
10
+ }
11
+ }
Original file line number Diff line number Diff line change
1
+ public class Solution {
2
+ public static void main(String[] args) {
3
+ int my_Int = 9;
4
+ // write your code logic here !!
5
+ double res=(double)my_Int;
6
+ System.out.println(my_Int);
7
+ System.out.println(res);
8
+ }
9
+ }
Original file line number Diff line number Diff line change
1
+
2
+ import java.util.Scanner;
3
+ public class Solution {
4
+ public static void main(String[] args) {
5
+ // write your code logic ...
6
+ Scanner sc = new Scanner(System.in);
7
+ byte age = sc.nextByte();
8
+ double income = sc.nextDouble();
9
+ boolean b=sc.nextBoolean();
10
+ if(!b && age>=18 && income>=20000)
11
+ {
12
+ System.out.println("You are eligible for the loan.");
13
+ }
14
+ else{
15
+ System.out.println("You are not eligible for the loan.");
16
+ }
17
+
18
+
19
+ }
20
+ }
Original file line number Diff line number Diff line change
1
+ import java.util.Scanner;
2
+ public class Solution
3
+ {
4
+ public static void main(String[] args)
5
+ {
6
+ // write your code here
7
+ Scanner sc = new Scanner(System.in);
8
+ int a = sc.nextInt();
9
+ int b = sc.nextInt();
10
+ int c = sc.nextInt();
11
+ int max = a>b? a>c ? a:c : b>c? b:c;
12
+ System.out.println(max);
13
+ }
14
+ }
Original file line number Diff line number Diff line change
1
+ import java.util.Scanner;
2
+ public class Solution
3
+ {
4
+ public static void main(String[] args)
5
+ {
6
+ // write your code logic here !!
7
+ Scanner sc = new Scanner(System.in);
8
+ int a = sc.nextInt();
9
+ int b=sc.nextInt();
10
+ int c= sc.nextInt();
11
+ String res="";
12
+ if(a+b <=c || a+c<=b || b+c<=a)
13
+ {
14
+ res+="Not a Triangle";
15
+ }
16
+ else if(a==b && a==c)
17
+ {
18
+ res+="Equilateral Triangle";
19
+ }
20
+ else if(a==b || a==c || b==c)
21
+ {
22
+ res+="Isosceles Triangle";
23
+ }
24
+ else{
25
+ res+="Scalene Triangle";
26
+ }
27
+ System.out.println(res);
28
+
29
+
30
+
31
+ }
32
+ }
Original file line number Diff line number Diff line change
1
+ import java.util.*;
2
+
3
+
4
+ public class Solution
5
+ {
6
+ public static void main(String[] args) {
7
+ Scanner sc = new Scanner(System.in);
8
+ int n=sc.nextInt();
9
+ String res=n%5==0 ? "Multiple of 5":"Not a Multiple of 5";
10
+ System.out.println(res);
11
+ }
12
+ }
Original file line number Diff line number Diff line change
1
+ import java.util.Scanner;
2
+
3
+ public class Solution{
4
+ public static void main(String[] args) {
5
+ //Write your code here.
6
+ Scanner sc = new Scanner(System.in);
7
+ int bs=sc.nextInt();
8
+ double ts = bs + 0.2*bs + 0.5*bs-0.11* bs;
9
+ char gr=sc.next().charAt(0);
10
+ int all=0;
11
+ if(gr=='A')
12
+ {
13
+ all=1700;
14
+ }
15
+ else if(gr=='B')
16
+ {
17
+ all=1500;
18
+ }
19
+ else {
20
+ all=1300;
21
+ }
22
+ ts=ts+all;
23
+ System.out.println(Math.round(ts));
24
+ }
25
+ }
Original file line number Diff line number Diff line change
1
+
2
+
3
+ import java.util.Scanner;
4
+ public class Solution {
5
+ public static void main(String[] args) {
6
+ // write your code logic here !!
7
+ Scanner sc = new Scanner(System.in);
8
+ byte age=sc.nextByte();
9
+ if(age>=65)
10
+ {
11
+ System.out.println("Seniors");
12
+ }
13
+ else if(age>=13)
14
+ {
15
+ System.out.println("Adults");
16
+ }
17
+ else if(age>=5)
18
+ {
19
+ System.out.println("Children");
20
+ }
21
+ else{
22
+ System.out.println("Infants");
23
+ }
24
+
25
+ }
26
+ }
Original file line number Diff line number Diff line change
1
+ import java.util.Scanner;
2
+ public class Solution
3
+ {
4
+ public static void main(String[] args)
5
+ {
6
+ // write your code ..
7
+ Scanner sc = new Scanner(System.in);
8
+ int grade=sc.nextInt();
9
+ if(grade>100 )
10
+ {
11
+ System.out.println("Invalid score");
12
+ }
13
+ else if(grade>=90 )
14
+ {
15
+ System.out.println("A");
16
+ }
17
+ else if(grade>=80 )
18
+ {
19
+ System.out.println("B");
20
+ }
21
+ else if(grade>=70 )
22
+ {
23
+ System.out.println("C");
24
+ }else if(grade>=60 )
25
+ {
26
+ System.out.println("D");
27
+ }else
28
+ {
29
+ System.out.println("F");
30
+ }
31
+
32
+ }
33
+ }
Original file line number Diff line number Diff line change
1
+ import java.util.*;
2
+
3
+
4
+ public class Solution
5
+ {
6
+ public static void main(String[] args) {
7
+ Scanner sc=new Scanner(System.in);
8
+ int a=sc.nextInt();
9
+ if(a<0)
10
+ {
11
+ System.out.println("Negative");
12
+ }
13
+ else{
14
+ System.out.println("Positive");
15
+ }
16
+ }
17
+ }
You can’t perform that action at this time.
0 commit comments