import java.util.Scanner ;
class Masa {
public static void main
( String [ ] args
) { double waga = 100 ;
Scanner input
= new Scanner
( System .
in ) ; System .
out .
println ( "Podaj swoja wage" ) ; waga = input.nextDouble ( ) ;
input.close ( ) ;
double masa = waga / Planeta.ZIEMIA .przeliczGrawitacje ( ) ;
// petla foreach
for ( Planeta p : Planeta.values ( ) )
System .
out .
printf ( "twoja masa na %s wynosi %f kilogramów\n " , p, p
.przeliczMasy ( masa) ) ;
}
public enum Planeta {
MERKURY( 3.303e+ 23, 2.4397e6) , WENUS( 4.869e+ 24, 6.0518e6) , ZIEMIA(
5.976e+ 24, 6.37814e6) , MARS( 6.421e+ 23, 3.3972e6) , JOWISZ(
1.9e+ 27, 7.1492e7) , SATURN( 5.688e+ 26, 6.0268e7) , URAN(
8.686e+ 25, 2.5559e7) , NEPTUN( 1.024e+ 26, 2.4746e7) , PLUTON(
1.27e+ 22, 1.137e6) ;
private final double masa; // w kilogramach
private final double promien; // w metrach
Planeta( double masa, double promien) {
this .masa = masa;
this .promien = promien;
}
public double masa( ) {
return masa;
}
public double radius( ) {
return promien;
}
// uniwersalna stała grawitacyjna (m3 kg-1 s-2)
public static final double G = 6.67300E- 11;
public double przeliczGrawitacje( ) {
return G * masa / ( promien * promien) ;
}
public double przeliczMasy( double Masa) {
return Masa * przeliczGrawitacje( ) ;
}
}
}
aW1wb3J0IGphdmEudXRpbC5TY2FubmVyOwoKY2xhc3MgTWFzYSB7CiAKICAgICAgICBwdWJsaWMgc3RhdGljIHZvaWQgbWFpbihTdHJpbmdbXSBhcmdzKSB7CiAgICAgICAgICAgICAgICBkb3VibGUgd2FnYSA9IDEwMDsKICAgICAgICAJCVNjYW5uZXIgaW5wdXQgPSBuZXcgU2Nhbm5lcihTeXN0ZW0uaW4pOwogICAgICAgIAkJU3lzdGVtLm91dC5wcmludGxuKCJQb2RhaiBzd29qYSB3YWdlIik7CiAgICAgICAgCQl3YWdhID0gaW5wdXQubmV4dERvdWJsZSgpOwogICAgICAgICAgICAgICAgaW5wdXQuY2xvc2UoKTsKICAgICAgICAgICAgICAgIGRvdWJsZSBtYXNhID0gd2FnYSAvIFBsYW5ldGEuWklFTUlBLnByemVsaWN6R3Jhd2l0YWNqZSgpOwogICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAvLyBwZXRsYSBmb3JlYWNoCiAgICAgICAgICAgICAgICBmb3IgKFBsYW5ldGEgcCA6IFBsYW5ldGEudmFsdWVzKCkpCiAgICAgICAgICAgICAgICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRmKCJ0d29qYSBtYXNhIG5hICVzIHd5bm9zaSAlZiBraWxvZ3JhbcOzd1xuIiwgcCwgcAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLnByemVsaWN6TWFzeShtYXNhKSk7CiAKICAgICAgICB9CiAKICAgICAgICBwdWJsaWMgZW51bSBQbGFuZXRhIHsKICAgICAgICAgICAgICAgIE1FUktVUlkoMy4zMDNlKzIzLCAyLjQzOTdlNiksIFdFTlVTKDQuODY5ZSsyNCwgNi4wNTE4ZTYpLCBaSUVNSUEoCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgNS45NzZlKzI0LCA2LjM3ODE0ZTYpLCBNQVJTKDYuNDIxZSsyMywgMy4zOTcyZTYpLCBKT1dJU1ooCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgMS45ZSsyNywgNy4xNDkyZTcpLCBTQVRVUk4oNS42ODhlKzI2LCA2LjAyNjhlNyksIFVSQU4oCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgOC42ODZlKzI1LCAyLjU1NTllNyksIE5FUFRVTigxLjAyNGUrMjYsIDIuNDc0NmU3KSwgUExVVE9OKAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDEuMjdlKzIyLCAxLjEzN2U2KTsKIAogICAgICAgICAgICAgICAgcHJpdmF0ZSBmaW5hbCBkb3VibGUgbWFzYTsgLy8gdyBraWxvZ3JhbWFjaAogICAgICAgICAgICAgICAgcHJpdmF0ZSBmaW5hbCBkb3VibGUgcHJvbWllbjsgLy8gdyBtZXRyYWNoCiAKICAgICAgICAgICAgICAgIFBsYW5ldGEoZG91YmxlIG1hc2EsIGRvdWJsZSBwcm9taWVuKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMubWFzYSA9IG1hc2E7CiAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMucHJvbWllbiA9IHByb21pZW47CiAgICAgICAgICAgICAgICB9CiAKICAgICAgICAgICAgICAgIHB1YmxpYyBkb3VibGUgbWFzYSgpIHsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIG1hc2E7CiAgICAgICAgICAgICAgICB9CiAKICAgICAgICAgICAgICAgIHB1YmxpYyBkb3VibGUgcmFkaXVzKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcHJvbWllbjsKICAgICAgICAgICAgICAgIH0KIAogICAgICAgICAgICAgICAgLy8gdW5pd2Vyc2FsbmEgc3RhxYJhIGdyYXdpdGFjeWpuYSAobTMga2ctMSBzLTIpCiAgICAgICAgICAgICAgICBwdWJsaWMgc3RhdGljIGZpbmFsIGRvdWJsZSBHID0gNi42NzMwMEUtMTE7CiAKICAgICAgICAgICAgICAgIHB1YmxpYyBkb3VibGUgcHJ6ZWxpY3pHcmF3aXRhY2plKCkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gRyAqIG1hc2EgLyAocHJvbWllbiAqIHByb21pZW4pOwogICAgICAgICAgICAgICAgfQogCiAgICAgICAgICAgICAgICBwdWJsaWMgZG91YmxlIHByemVsaWN6TWFzeShkb3VibGUgTWFzYSkgewogICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gTWFzYSAqIHByemVsaWN6R3Jhd2l0YWNqZSgpOwogICAgICAgICAgICAgICAgfQogICAgICAgIH0KIAp9