File tree Expand file tree Collapse file tree 2 files changed +51
-2
lines changed Expand file tree Collapse file tree 2 files changed +51
-2
lines changed Original file line number Diff line number Diff line change
1
+ package binod ;
2
+ import java .util .Scanner ;
3
+ //question 1: 2 times
4
+
5
+ class Question2 {
6
+ public static void main (String [] args ) {
7
+ Scanner sc = new Scanner (System .in );
8
+ int sumofodd = 0 ;
9
+ int sumofeven = 0 ;
10
+ Boolean permission = true ;
11
+ do {
12
+ System .out .println ("Enter an number" );
13
+ int n = sc .nextInt ();
14
+ if (n % 2 == 0 ) {
15
+ sumofeven += n ;
16
+ } else {
17
+ sumofodd += n ;
18
+ }
19
+ System .out .println ("Do you wanna continue ? true/false" );
20
+ permission = sc .nextBoolean ();
21
+ } while (permission == true );
22
+ System .out .println ("Sum of Even =" + sumofeven );
23
+ System .out .println ("Sum of Odd=" + sumofodd );
24
+ }
25
+ }
26
+
27
+ public class LoopsQuestions {
28
+ public static void main (String [] args ) {
29
+ Scanner sc = new Scanner (System .in );
30
+ System .out .println ("Enter a number" );
31
+ int n = sc .nextInt ();
32
+ int f = n ;
33
+ for (int i = 1 ; i < n ; i ++) {
34
+ f = f * (n - i );
35
+ }
36
+ System .out .println (f );
37
+ }
38
+ }
39
+
40
+ class Question4 {
41
+ public static void main (String [] args ) {
42
+ Scanner sc = new Scanner (System .in );
43
+ System .out .println ("Enter a number" );
44
+ int n = sc .nextInt ();
45
+ for (int i = 1 ; i <= 10 ; i ++) {
46
+ System .out .println (n * i );
47
+ }
48
+ }
49
+ }
Original file line number Diff line number Diff line change 1
1
package oop ;
2
2
public class Animal {
3
3
String name ;
4
+
4
5
float weight ;
5
- String size ;
6
6
7
+ String size ;
7
8
//a constructor is an especial method that execute at the beginning when object of class is created.
8
9
9
10
//no parameterized
10
11
Animal () {
11
-
12
12
}
13
13
14
14
//parameterized
You can’t perform that action at this time.
0 commit comments