Skip to content

Commit eb758c9

Browse files
Add files via upload
1 parent 343ea80 commit eb758c9

File tree

5 files changed

+107
-0
lines changed

5 files changed

+107
-0
lines changed

Diff for: src/question1.java

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package exam;
2+
3+
public class question1 {
4+
public static void main(String args[])
5+
{
6+
for(int a = 1; a <= 5; a++)
7+
{
8+
for(int b = 5; b > a; b--)
9+
{
10+
System.out.print(" ");
11+
}
12+
for(int c = 0; c < a; c++)
13+
{
14+
System.out.print("* ");
15+
}
16+
System.out.print("\n");
17+
}
18+
}
19+
20+
}

Diff for: src/question2.java

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package exam;
2+
3+
public class question2 {
4+
public static void main(String args[])
5+
{
6+
int[] GivenArray = {1, 6, 8, 4};
7+
int S = 0;
8+
9+
for (int Count = 0; Count < GivenArray.length; Count ++)
10+
{
11+
S += GivenArray[Count];
12+
}
13+
14+
System.out.println("Sum = " + S);
15+
}
16+
17+
}

Diff for: src/question3.java

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package exam;
2+
3+
import java.util.Scanner;
4+
5+
public class question3 {
6+
static int fact(int num){
7+
if(num == 0)
8+
return 1;
9+
else
10+
return(num * fact(num-1));
11+
}
12+
13+
public static void main(String[] args) {
14+
Scanner scanner = new Scanner(System.in);
15+
System.out.println("Enter Number: ");
16+
int num = scanner.nextInt();
17+
int facti = fact(num);
18+
19+
System.out.println("Factorial= "+facti);
20+
}
21+
}

Diff for: src/question4.java

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package exam;
2+
3+
public class question4 {
4+
public static void main(String[] args) {
5+
for(int a=3;a<=100;a++){
6+
int state = 0;
7+
for(int b=2;b<a;b++){
8+
if(a%b== 0)
9+
state++;
10+
}
11+
if(state == 0){
12+
System.out.print(a+", ");
13+
}
14+
}
15+
}
16+
17+
18+
}

Diff for: src/question5.java

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package exam;
2+
3+
import java.util.Scanner;
4+
5+
public class question5 {
6+
void DemoCount(String str){
7+
char[] inp = str.toCharArray();
8+
int vowels=0;
9+
int consonants=0;
10+
11+
for(int i=0; i<str.length(); i++){
12+
if(inp[i] == 'a' || inp[i] == 'e' || inp[i] == 'i' || inp[i] == 'o' || inp[i] == 'u'){
13+
vowels++;
14+
}
15+
else{
16+
consonants++;
17+
}
18+
}
19+
20+
System.out.println("Vowels = "+vowels+" and Consonants = "+consonants);
21+
}
22+
23+
public static void main(String[] args) {
24+
Scanner scanner = new Scanner(System.in);
25+
System.out.println("Input String: ");
26+
String str = scanner.next();
27+
28+
question5 countVowels = new question5();
29+
countVowels.DemoCount(str);
30+
}
31+
}

0 commit comments

Comments
 (0)