pacage jp.co.example.java15;</p>

<p>public class Main {
  public static void main(String[] args){
    for (int testNumber = 2; testNumber &lt;= 100; testNumber++){
      boolean isPrimeNumber = true;//mathtic
      for (int i = 2; i &lt; testNumber; i++) {
        if(testNumber % i == 0) {
          isPrimeNumber = false;
          break;
        }
      }</p>

<pre><code>  if (isPrimeNumber){ //functic
    System.out.println(testNumber);
  }
}
</code></pre>

<p>}
}</p>

<p>1
point
What is code ,what to do
be sure function</p>

<p>2
watch out valuable
boolean isPrimeNumber
int i
int testNumber</p>

<p>public class Main {
  public static void main(String[] args){
    for (int testNumber = 2; testNumber &lt;= 100; testNumber++){
      if (isPrimeNumber){
        System.out.println(testNumber);
      }
    }
  }
  private static boolean isPrimeNumber(int testNumber){
    for (int i = 2; i &lt; testNumber; i++){
      if(testNumber % i == 0){
        return false;
      }
    }
    return true;
  }
}</p>

<p>↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓</p>

<p>public class Main {
  public static void main(String[] args){
    for (int testNumber = 2; testNumber &lt;= 100; testNumber++){
      boolean isPrimeNumber = isPrimeNumber(testNumber);
      if (isPrimeNumber){
        System.out.println(testNumber);
      }
    }
  }
  private static boolean isPrimeNumber(int testNumber){
    for (int i = 2; i &lt; testNumber; i++){
      if(testNumber % i == 0){
        return false;
      }
    }
    return true;
  }
}</p>

<p>↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
//individaul
public class Main {
  public static void main(String[] args){
    for (int testNumber = 2; testNumber &lt;= 100; testNumber++){//functic
      if (isPrimeNumber(testNumber)){
        System.out.println(testNumber);
      }
    }
  }
  private static boolean isPrimeNumber(int testNumber){//mathtic
    for (int i = 2; i &lt; testNumber; i++){
      if(testNumber % i == 0){
        return false;
      }
    }
    return true;
  }
}</p>

<p>/////////////////////////////
///
///
///
public class Main {
  public static void main(String[] args){
    //arrange Item
    Item pencil = new Item(&quot;umi-hb-001&quot;,&quot;umi HB&quot;, &quot;yotsubisienpitsu&quot;, &quot;120&quot;);
    //view Item
    System.out.println(&quot;item&quot;);</p>

<pre><code>//enpitu
System.out.println(&amp;quot;itemCode&amp;quot; + pencil.getCode());
System.out.println(&amp;quot;itemname&amp;quot; + pencil.getName());
System.out.println(&amp;quot;itemmaker&amp;quot; + pencil.getMaker());
System.out.println(&amp;quot;itemPrice&amp;quot; + pencil.getPrice());
</code></pre>

<p>}
}</p>

<p>///////////////////////////////
public class Item {
  private final String code;
  private final String name;
  private final String maker;
  private final int price;
  public Item(String code, String name, String maker, int price){
    super();
    this.code = code;
    this.name = name;
    this.maker = maker;
    this.price = price;
  }
  public String getCode(){
    return code;
  }
  public String getName(){
    return name;
  }
  public String getMaker(){
    return maker;
  }
  public String getPrice(){
    return price;
  }
}

(Visited 1 times, 1 visits today)

コメントを残す

メールアドレスが公開されることはありません。