[AtCoder Problem-ABC001] C-Do wind observation in Java [Code]

Introduction

Now that I have completed my studies of Java-Silver, I tried "AtCoder Problem" which can output for free. I will leave a memorandum on Qiita!

problem

Since the problem statement is long, please use here.

code

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 ;
  }

}

Please forgive me that the code is verbose and the variable names are messy. I would like to write the original code of the spirit that "I should move first" and improve the quality of the code from now on.

$ java WindObservation
> 2750
> 628
W
5
$ java WindObservation
> 1687
> 1029
SSE
8

It's working, so it's safe! !! !!

I will output it with AtCoder Problem for a while. When Corona calms down, I would like to take Java-Silver and challenge Gold.

Recommended Posts

[AtCoder Problem-ABC001] C-Do wind observation in Java [Code]
Java in Visual Studio Code
Write Java8-like code in Java8
Solve AtCoder Beginner Contest 151 in java
Guess the character code in Java
Solve AtCoder Beginner Contest 150 in java
Java Spring environment in vs Code
Solve AtCoder Beginner Contest 153 in java
Solve AtCoder Beginner Contest 175 in java
Solve AtCoder Beginner Contest 160 in java
Solve AtCoder Beginner Contest 152 in java
Solve AtCoder Beginner Contest 156 in java
All same hash code string in Java
[Mac] Install Java in Visual Studio Code
[Code] Forcibly breaks through the C problem "* 3 or / 2" of [AtCoder Problem-ABC100] with Java [Code]
Add --enable-preview option in Java in Visual Studio Code
Technology for reading Java source code in Eclipse
Static code analysis with Checkstyle in Java + Gradle
Code to escape a JSON string in Java
Try using Sourcetrail (win version) in Java code
Try using Sourcetrail (macOS version) in Java code
[Java beginner's anguish] Hard-to-test code implemented in Junit
[Mac] Install Java in Visual Studio Code (VS Code)
Script Java code
Java code TIPS
Partization in Java
Java sample code 02
Java sample code 03
Changes in Java 11
Java sample code 04
Java sample code 01
Java character code
Pi in Java
FizzBuzz in Java
Sample code to convert List to List <String> in Java Stream
Do not write if (isAdmin == true) code in Java
Java11: Run Java code in a single file as is
Differences in code when using the length system in Java