-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTask3 (1).java
More file actions
53 lines (45 loc) · 987 Bytes
/
Copy pathTask3 (1).java
File metadata and controls
53 lines (45 loc) · 987 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import java.util.ArrayList;
import java.util.Scanner;
class Array{
ArrayList<Integer> list=new <Integer>ArrayList();
int max = 0;
void show(){
int count=0;
Scanner input=new Scanner(System.in);
System.out.println("Enter numbers");
int num=input.nextInt();
while(num != 0 )
{
list.add(num);
num=input.nextInt();
count=count+num;
}
System.out.println(count);
}
void maxNumber()
{
for (int i = 0; i < list.size(); i++) {
if (list.get(i) > max)
max = list.get(i);
}
}
public String toString(){
return ("The largest number in the input is " + max);
}
}
class Task3{
public static void main(String[] args)
{
Array[] p=new Array[1];
p[0]= new Array();
for(int i=0;i<p.length;i++)
{
p[i].show();
}
for(int i=0;i<p.length;i++)
{
p[i].maxNumber();
System.out.println(p[i]);
}
}
}