Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 90b5ca7

Browse files
committed
exercise 12 completed
1 parent a515285 commit 90b5ca7

File tree

2 files changed

+51
-2
lines changed

2 files changed

+51
-2
lines changed

src/binod/LoopsQuestions.java

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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+
}

src/oop/Animal.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
package oop;
22
public class Animal {
33
String name;
4+
45
float weight;
5-
String size;
66

7+
String size;
78
//a constructor is an especial method that execute at the beginning when object of class is created.
89

910
//no parameterized
1011
Animal() {
11-
1212
}
1313

1414
//parameterized

0 commit comments

Comments
 (0)