Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Ø
Øving 1
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Package registry
Operate
Terraform modules
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Programmering 1 Øvinger
Øving 1
Commits
a7ebb981
Commit
a7ebb981
authored
7 months ago
by
Benjamin Kvello-Hansen
Browse files
Options
Downloads
Patches
Plain Diff
Update 2 files
- /oppgave2.java - /oppgave3.java
parent
f4ed12ed
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
oppgave2.java
+34
-0
34 additions, 0 deletions
oppgave2.java
oppgave3.java
+33
-0
33 additions, 0 deletions
oppgave3.java
with
67 additions
and
0 deletions
oppgave2.java
+
34
−
0
View file @
a7ebb981
import
java.util.*
;
public
class
Oppgave2
{
static
double
tidsomregning
(
double
hr
,
double
min
,
double
sec
){
double
totSec
=
hr
*
60
*
60
+
min
*
60
+
sec
;
System
.
out
.
println
(
hr
+
" timer/time, "
+
min
+
" minutter/minutt og "
+
sec
+
" sekunder/sekund er totalt "
+
totSec
+
" sekunder/sekund"
);
return
totSec
;
}
public
static
void
main
(
String
[]
args
){
System
.
out
.
println
(
"Hvor mange timer? "
);
Scanner
inpHr
=
new
Scanner
(
System
.
in
);
double
hr
=
inpHr
.
nextFloat
();
System
.
out
.
println
(
"Hvor mange minutter? "
);
Scanner
inpMin
=
new
Scanner
(
System
.
in
);
double
min
=
inpMin
.
nextFloat
();
System
.
out
.
println
(
"Hvor mange sekunder? "
);
Scanner
inpSec
=
new
Scanner
(
System
.
in
);
double
sec
=
inpSec
.
nextFloat
();
tidsomregning
(
hr
,
min
,
sec
);
//datasett
tidsomregning
(
30
,
1
,
1
);
tidsomregning
(
1
,
1
,
1
);
tidsomregning
(
1
,
30
,
1
);
tidsomregning
(
48
,
21
,
1
);
tidsomregning
(
0
,
0
,
1
);
tidsomregning
(
7
,
33
,
2
);
tidsomregning
(
1
,
400
,
200
);
tidsomregning
(
0
,
103
,
0
);
}
}
This diff is collapsed.
Click to expand it.
oppgave3.java
0 → 100644
+
33
−
0
View file @
a7ebb981
import
java.util.*
;
public
class
Oppgave3
{
static
int
tidsomregning
(
int
totSec
){
int
hr
=
totSec
/
(
60
*
60
);
var
tempSec
=
totSec
-(
hr
*
60
*
60
);
int
min
=
tempSec
/
60
;
tempSec
=
tempSec
-(
min
*
60
);
int
sec
=
tempSec
;
System
.
out
.
println
(
totSec
+
" Sekunder, er "
+
hr
+
" timer, "
+
min
+
" minutter og "
+
sec
+
" sekunder"
);
return
1
;
}
public
static
void
main
(
String
[]
args
){
System
.
out
.
println
(
"Hvor mange sekunder vil du ha i timer, minutter og sekund? "
);
Scanner
inpSec
=
new
Scanner
(
System
.
in
);
final
int
totSec
=
inpSec
.
nextInt
();
tidsomregning
(
totSec
);
//datasett
tidsomregning
(
10
);
tidsomregning
(
300
);
tidsomregning
(
4620
);
tidsomregning
(
3661
);
tidsomregning
(
9384
);
tidsomregning
(
2836
);
tidsomregning
(
1298723
);
tidsomregning
(
1
);
tidsomregning
(
60
);
}
}
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