Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

why does not my code work for number 224??

+1 vote
asked Nov 5, 2018 by Meghdad (130 points)
import java.util.*;

public class Main

{

  static Scanner in = new Scanner (System.in);

  public static void main (String[]args)

  {

    int even;

    do

      {

System.out.println ("enter an even number except 2 : ");

even = in.nextInt ();

      }

    while (even % 2 != 0 || even == 2);

    int half = even / 2;

    int half2 = half;

    int j = 2;

    int i = 2;

    for (i = 2; i < half; i++)

      {

if (half % i == 0)

  {

    half++;

    half2--;

    i = 2;

  }

if (i == (half - 1)){

  for (j = 2; j < half2; j++)

    if (half2 % j == 0)

      {

half++;

half2--;

j = 2;

      }

}

if (j == (half2-1))

  break;

      }

    System.out.println ("even = " + half + " + " + half2);

  }

}

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...