Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
statistics with methods
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SOFT Core
SOFT 160
statistics with methods
Commits
b46f356e
Commit
b46f356e
authored
3 years ago
by
Christopher Bohn
Browse files
Options
Downloads
Patches
Plain Diff
Extracted getUserInput as a helper method for multiple methods
parent
0d63a2d9
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/edu/unl/cse/soft160/statistics/Statistics.java
+11
-4
11 additions, 4 deletions
src/main/java/edu/unl/cse/soft160/statistics/Statistics.java
with
11 additions
and
4 deletions
src/main/java/edu/unl/cse/soft160/statistics/Statistics.java
+
11
−
4
View file @
b46f356e
...
@@ -10,15 +10,22 @@ public class Statistics {
...
@@ -10,15 +10,22 @@ public class Statistics {
MEAN
,
MEDIAN
,
MAXIMUM
,
MINIMUM
,
MEAN
,
MEDIAN
,
MAXIMUM
,
MINIMUM
,
}
}
private
static
String
getUserInput
(
String
prompt
,
Scanner
scanner
)
{
System
.
out
.
print
(
prompt
);
String
userInput
=
scanner
.
nextLine
();
return
userInput
;
}
private
static
double
getValue
(
String
ordinal
,
Scanner
scanner
)
{
private
static
double
getValue
(
String
ordinal
,
Scanner
scanner
)
{
System
.
out
.
print
(
"Enter the "
+
ordinal
+
" value: "
);
String
userInput
=
getUserInput
(
"Enter the "
+
ordinal
+
" value: "
,
scanner
);
double
value
=
Double
.
parseDouble
(
scanner
.
nextLine
());
double
value
;
value
=
Double
.
parseDouble
(
userInput
);
return
value
;
return
value
;
}
}
private
static
StatisticsType
getStaticsticsType
(
Scanner
scanner
)
{
private
static
StatisticsType
getStaticsticsType
(
Scanner
scanner
)
{
S
ystem
.
out
.
prin
t
(
"Please enter the statistic to calculate: "
);
S
tring
userInput
=
getUserInpu
t
(
"Please enter the statistic to calculate: "
,
scanner
);
String
userInput
=
scanner
.
nextLine
()
.
toUpperCase
();
userInput
=
userInput
.
toUpperCase
();
StatisticsType
statisticsType
=
StatisticsType
.
valueOf
(
userInput
);
StatisticsType
statisticsType
=
StatisticsType
.
valueOf
(
userInput
);
return
statisticsType
;
return
statisticsType
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment