Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
CompanyProj
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nelimajain2511
CompanyProj
Commits
43822260
Commit
43822260
authored
Feb 21, 2023
by
nelimajain2511
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
a31df362
Pipeline
#2881
failed with stages
in 1 second
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
80 additions
and
0 deletions
+80
-0
EngineerFirm.java
src/com/altimetrik/EngineerFirm.java
+80
-0
No files found.
src/com/altimetrik/EngineerFirm.java
0 → 100644
View file @
43822260
package
com
.
altimetrik
;
import
java.util.Arrays
;
import
java.util.IntSummaryStatistics
;
import
java.util.List
;
import
java.util.stream.Collectors
;
public
class
EngineerFirm
{
private
final
int
[]
income
;
public
EngineerFirm
(
int
count
)
{
income
=
new
int
[
count
];
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
income
[
i
]
=
0
;
}
}
public
static
void
printMessages
(
double
salaryAmount
,
String
salarySpecification
,
String
profession
)
{
switch
(
salarySpecification
)
{
case
"max"
:
System
.
out
.
print
(
"Maximum salary amongst "
+
profession
);
System
.
out
.
printf
(
" is %d"
,
(
int
)
salaryAmount
);
System
.
out
.
println
(
""
);
break
;
case
"min"
:
System
.
out
.
print
(
"Minimum salary amongst "
+
profession
);
System
.
out
.
printf
(
" is %d"
,
(
int
)
salaryAmount
);
System
.
out
.
println
(
""
);
break
;
case
"ave"
:
System
.
out
.
print
(
"Average salary of "
+
profession
);
System
.
out
.
printf
(
" is %.2f"
,
salaryAmount
);
System
.
out
.
println
(
""
);
break
;
default
:
System
.
out
.
println
(
"Incomes of "
+
profession
+
" credited"
);
break
;
}
}
public
void
assignSalaries
(
int
[]
salaries
)
{
if
(
salaries
!=
null
)
{
assignIncome
(
salaries
);
printMessages
(
0
,
""
,
"engineers"
);
}
}
public
void
maxSalary
()
{
printMessages
(
MaxSalary
(),
"max"
,
"engineers"
);
}
public
void
minSalary
()
{
printMessages
(
MinSalary
(),
"min"
,
"engineers"
);
}
public
void
averageSalary
()
{
printMessages
(
AveSalary
(),
"ave"
,
"engineers"
);
}
public
Integer
MaxSalary
()
{
List
<
Integer
>
list
=
Arrays
.
stream
(
income
).
boxed
().
collect
(
Collectors
.
toList
());
return
list
.
stream
().
max
(
Integer:
:
compare
).
get
();
}
public
Integer
MinSalary
()
{
List
<
Integer
>
list
=
Arrays
.
stream
(
income
).
boxed
().
collect
(
Collectors
.
toList
());
return
list
.
stream
().
min
(
Integer:
:
compare
).
get
();
}
public
double
AveSalary
()
{
List
<
Integer
>
list
=
Arrays
.
stream
(
income
).
boxed
().
collect
(
Collectors
.
toList
());
IntSummaryStatistics
stats
=
list
.
stream
().
mapToInt
((
x
)
->
x
).
summaryStatistics
();
return
stats
.
getAverage
();
}
public
void
assignIncome
(
int
[]
salaries
)
{
System
.
arraycopy
(
salaries
,
0
,
income
,
0
,
Math
.
min
(
income
.
length
,
salaries
.
length
));
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment