Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
input-output
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor 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
Brady James Garvin
input-output
Commits
ed02b45a
Commit
ed02b45a
authored
8 years ago
by
Brady James Garvin
Browse files
Options
Downloads
Patches
Plain Diff
Modified summation for demonstrations of try/catch and refactoring for reuse.
parent
2e328679
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
sum/src/main/java/edu/unl/cse/soft160/sum/Sum.java
+13
-9
13 additions, 9 deletions
sum/src/main/java/edu/unl/cse/soft160/sum/Sum.java
with
13 additions
and
9 deletions
sum/src/main/java/edu/unl/cse/soft160/sum/Sum.java
+
13
−
9
View file @
ed02b45a
...
...
@@ -3,14 +3,18 @@ package edu.unl.cse.soft160.sum;
import
java.util.Scanner
;
public
class
Sum
{
public
static
void
main
(
String
[]
args
)
{
Scanner
firstScanner
=
new
Scanner
(
args
[
0
]);
double
firstNumber
=
firstScanner
.
nextDouble
();
firstScanner
.
close
();
Scanner
secondScanner
=
new
Scanner
(
args
[
1
]);
double
secondNumber
=
secondScanner
.
nextDouble
();
secondScanner
.
close
();
double
sum
=
firstNumber
+
secondNumber
;
System
.
out
.
println
(
"The sum is "
+
sum
+
"."
);
public
static
void
main
(
String
...
arguments
)
{
double
augend
=
0
,
firstAddend
=
0
,
secondAddend
=
0
;
Scanner
scanner
=
new
Scanner
(
System
.
in
);
System
.
out
.
print
(
"Enter the augend: "
);
augend
=
scanner
.
nextDouble
();
System
.
out
.
print
(
"Enter the first addend: "
);
firstAddend
=
scanner
.
nextDouble
();
System
.
out
.
print
(
"Enter the second addend: "
);
secondAddend
=
scanner
.
nextDouble
();
scanner
.
close
();
String
message
=
augend
+
" + "
+
firstAddend
+
" + "
+
secondAddend
+
" = "
+
(
augend
+
firstAddend
+
secondAddend
);
System
.
out
.
println
(
message
);
}
}
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