-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHomeWorkOOP1
More file actions
237 lines (131 loc) · 3.82 KB
/
HomeWorkOOP1
File metadata and controls
237 lines (131 loc) · 3.82 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
// Task1 and 2.
/*
public class Triangle {
// Attributes
int area;
Triangle ( )
{
area= (4*2)/2;
}
}
*/
/*
public class player {
String name;
int playerID;
player (String i, int j) // Constructor
{
name=i;
playerID=j;
}
}
*/
/*
import java.util.*;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
// Task1
player obj= new player ("Mosa", 2);
System.out.println(" Task1**************\n\n The name of player is : " + obj.name + "\n The PlayerID is : " + obj.playerID);
// Task2
Triangle obj1= new Triangle();
System.out.println(" \nTask2*************** \nThe are of triangle is : "+ obj1.area);
*/
// *******************************************************************************************
// Task3
/*
import java.util.*;
public class Average {
static void method(float x, float y,float z, float a , float b)
{
float avg= (x+y+z+a+b)/5;
System.out.println(avg);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("Enter the 5 number for which you get average.");
Scanner input= new Scanner(System.in);
float num1= input.nextFloat();
float num2= input.nextFloat();
float num3= input.nextFloat();
float num4= input.nextFloat();
float num5= input.nextFloat();
method( num1 , num2 , num3 , num4 , num5);
}
}
*/
// *******************************************************************************************************
// Task 4
/*
import java.util.*;
public class Employee {
static void method( String a, int b, String c)
{
System.out.println("\t\t\t\t\tName " + " Year of Joining " + " Addresss ");
System.out.println("\t\t\t\t\t"+a+ " "+" " +b +" "+c);
// String ret="\t\t\t\t\t"+a+ " "+" " +b +" "+c;
//return ret;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner var= new Scanner(System.in);
//String store="";
System.out.println("For how mnay Employee you want to enter the data ?");
int numOfemply = var.nextInt();
for(int i=1; i<numOfemply+1; i++)
{
System.out.println("Enter the data of "+ i + "Employee .");
Scanner input= new Scanner(System.in);
System.out.println("Name : ");
String str= input.nextLine();
System.out.println("Year : ");
int num = input.nextInt( );
System.out.println("Address :");
String out= input.nextLine();// I dont know how can we get two String input.
String out1= input.nextLine();
//store= method(str, num, out1);
method(str, num, out1);
}
// System.out.println(store);
}
}
*/
//**********************************************************************************************************
// task 5
import java.util.*;
public class Finder {
public static void main(String[] args) {
// TODO Auto-generated method stub
int array[]= new int[10];
Scanner input= new Scanner(System.in);
//int num= input.nextInt();
System.out.print("Enter the elements of arrray.");
for(int i= 0; i<10; i++)
{
array[i]= input.nextInt();
}
System.out.print("The array is : \n{ ");
for(int i= 0; i<10; i++)
{
System.out.print(" "+array[i]);
}
System.out.println(" }");
int max= array[0];
int min = array[9];
for(int i = 0; i<10; i++)
{
if (max<=array[i])
{
max=array[i];
}
if (min>=array[i])
{
min = array[i];
}
}
System.out.println( "The greatest number in the array is : "+max + " \nThe lowest number in the array is : "+ min);
}
}
}
}