Nachdem ich mein Studium von Java-Silver abgeschlossen habe, habe ich "AtCoder Problem" ausprobiert, das kostenlos ausgegeben werden kann. Ich werde ein Memorandum über Qiita hinterlassen!
Da die Problemstellung lang ist, bitte hier
TorT.java
import java.util.Scanner;
public class WindObservation {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
double wind_direction = sc.nextInt();
wind_direction = wind_direction / 10;
double Wind = sc.nextInt();
Wind = Wind / 60;
Wind = ((double)Math.round(Wind * 10))/10;
System.out.println(Direction(wind_direction));
System.out.println(Amount(Wind));
}
public static String Direction(double direction){
String master = "";
if((11.25 <= direction) && (direction < 33.75)){
master = "N";
}else if((33.75 <= direction) && (direction < 56.25)){
master = "NE";
}else if((56.25 <= direction) && (direction < 78.75)){
master = "ENE";
}else if((78.75 <= direction) && (direction < 101.25)){
master = "E";
}else if((101.25 <= direction) && (direction < 123.75)){
master = "ESE";
}else if((123.75 <= direction) && (direction < 146.25)){
master = "SE";
}else if((146.25 <= direction) && (direction < 168.75)){
master = "SSE";
}else if((168.75 <= direction) && (direction < 191.25)){
master = "S";
}else if((191.25 <= direction) && (direction < 213.75)){
master = "SSW";
}else if((213.75 <= direction) && (direction < 236.25)){
master = "SW";
}else if((236.25 <= direction) && (direction < 258.75)){
master = "WSW";
}else if((258.75 <= direction) && (direction < 281.25)){
master = "W";
}else if((281.25 <= direction) && (direction < 303.75)){
master = "WNW";
}else if((303.75 <= direction) && (direction < 326.25)){
master = "NW";
}else if((326.25 <= direction) && (direction < 348.75)){
master = "NNW";
}else{
master = "N";
}
return master;
}
public static int Amount(double wind){
int i = 0;
if((0.0 <= wind) && (wind < 0.2)){
i = 0;
}else if((0.3 <= wind) && (wind < 1.5)){
i = 1;
}else if((1.6 <= wind) && (wind < 3.3)){
i = 2;
}else if((3.4 <= wind) && (wind < 5.4)){
i = 3;
}else if((5.5 <= wind) && (wind < 7.9)){
i = 4;
}else if((8.0 <= wind) && (wind < 10.7)){
i = 5;
}else if((10.8 <= wind) && (wind < 13.8)){
i = 6;
}else if((13.9 <= wind) && (wind < 17.1)){
i = 7;
}else if((17.2 <= wind) && (wind < 20.7)){
i = 8;
}else if((20.8 <= wind) && (wind < 24.4)){
i = 9;
}else if((24.5 <= wind) && (wind < 28.4)){
i = 10;
}else if((28.5 <= wind) && (wind < 32.6)){
i = 11;
}else{
i = 12;
}
return i ;
}
}
Bitte verzeihen Sie mir, dass der Code langweilig ist und die Variablennamen unordentlich sind. Ich möchte den ursprünglichen Code des Geistes schreiben, dass "ich mich zuerst bewegen sollte" und von nun an die Qualität des Codes verbessern.
$ java WindObservation
> 2750
> 628
W
5
$ java WindObservation
> 1687
> 1029
SSE
8
Es funktioniert, also ist es sicher! !! !!
Ich werde es für eine Weile mit AtCoder Problem ausgeben. Wenn sich Corona beruhigt, möchte ich Java-Silber nehmen und Gold herausfordern.