Task1:
1 . Look at this series: 58, 52, 46, 40, 34,28 ... What number should come next?
24
26
25
22
Ans:
The series is decreasing by 6 each time:
58-6=52
52-6=46
46-6=40
40-6=34
34-6=28
So, continuing the pattern,28-6=22.
The next number in the series is 22.
Program:
package javaprogram;
public class number {
public static void main(String[] args) {
// TODO Auto-generated method stub
int num=58;
int count=1;
while(count<=7) {
System.out.println(num);
num=num-6;
count=count+1;
}
}
}
Output:
58
52
46
40
34
28
22
2.Look at this series: 3, 4, 7, 8, 11, 12,15,16,19 ... What number should come next?
17
20
21
19
Ans:
Let’s look at the pattern:
3->4 (add1)
4->7 (add3)
7->8 (add1)
8->11(add3)
11->12(add1)
12->15(add3)
15->16(add1)
16->19(add3)
It looks like the pattern alternates between adding 1 and adding
Following this pattern, the next step is to add 3 to 12, so:
19+1=20
The next number in the series is 20.
Program:
package javaprogram;
public class Numberseries1 {
public static void main(String[] args) {
// TODO Auto-generated method stub
int num=3;
int count=1;
while(count<=10) {
System.out.println(num);
num=num+1;
System.out.println(num);
num=num+3;
count=count+2;
}
}
}
Output:
3
4
7
8
11
12
15
16
19
20
3.Look at this series: 1.5, 2.3, 3.1, 3.9, 4.7, 5.5, 6.3,... What number should come next?
4.2
4.4
4.7
5.1
Ans:
Let’s examine the differences between the numbers in the series:
1.5 + 0.8 = 2.3
2.3 + 0.8 = 3.1
3.1 + 0.8 = 3.9
3.9 + 0.8 = 4.7
4.7 + 0.8 = 5.5
5.5 + 0.8 = 6.3
It looks like the series increases by 0.8 each time. So, to find the next number:
6.3 + 0.8 = 7.1
The next number in the series is 7.1.
Program:
package javaprogram;
public class floattask {
public static void main(String[] args) {
// TODO Auto-generated method stub
float no=1.5f;
int count=1;
while(count<=8) {
System.out.println(no);
no=no+0.8f;
count=count+1;
}
}
}
Output:
1.5
2.3
3.1
3.8999999
4.7
5.5
6.3
7.1000004
Top comments (0)