forked from pralg17/t01funktsioonid
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAlamprogramm1.java
More file actions
27 lines (27 loc) · 865 Bytes
/
Copy pathAlamprogramm1.java
File metadata and controls
27 lines (27 loc) · 865 Bytes
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
public class Alamprogramm1{
public static double sentimeetriteks(double tollid){
return tollid*2.54;
}
public static double tollideks(double sentimeetrid){
return sentimeetrid/2.54;
//arvutage sentimeetritest tollid
}
//Looge alamprogramm kolmnurga hüpotenuusi leidmiseks kaatetite järgi
//Ruutjuure funktsioon Math.sqrt
public static double hypotenuus(double a, double b){
return Math.sqrt(Math.pow(a, 2)+Math.pow(b, 2));
}
public static void main(String[] args){
double tollidearv=3;
double sentimeetritearv=sentimeetriteks(tollidearv);
System.out.println(tollidearv+" tolli on "+sentimeetritearv+" sentimeetrit");
System.out.println(String.format("Sentimeetreid: %.2f", tollideks(10)));
System.out.println(hypotenuus(3, 4));
}
}
/*
[jaagup@greeny algus]$ java Alamprogramm1
3.0 tolli on 7.62 sentimeetrit
Sentimeetreid: 3.94
5.0
*/