Results 1 to 4 of 4
  1. #1
    Aries. is offline Member
    Join Date
    Jan 2013
    Posts
    22
    Rep Power
    0

    Default [Java Eclipse] How to combine

    Sample output:
    Enter the numbers of input you want:3
    Enter number:2
    Enter number:5
    Enter number:3
    The even numbers are:2
    The odd numbers are:5 3

    And here's my coding :

    import java.util.Scanner;

    public class EditCodes {

    public static void main(String args[]){
    Scanner a = new Scanner (System.in);
    int loop;

    System.out.print("Enter the numbers of input you want: ");
    loop = a.nextInt();
    int num[] = new int[loop];

    for(int x=0;x<loop;x++){
    System.out.print("Enter number: ");
    num[x]=a.nextInt();
    }
    for(int i=0; i < num.length; i++){

    if(num[i]%2 == 0)
    System.out.println("The even numbers are: " + num[i]);
    else
    System.out.println("The odd numbers are: " + num[i]);
    }
    }
    }
    And the output something like this

    Enter the numbers of input you want: 3
    Enter number: 2
    Enter number: 5
    Enter number: 3
    The even numbers are: 2
    The odd numbers are: 5
    The odd numbers are: 3
    How to add or combine in one line? like the sample output above? Is there anyone would help me?

  2. #2
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    6

    Default Re: [Java Eclipse] How to combine

    declare two new arrays, one called odd and one called even. Add the numbers accordingly and use them for your output.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  3. #3
    Aries. is offline Member
    Join Date
    Jan 2013
    Posts
    22
    Rep Power
    0

    Default Re: [Java Eclipse] How to combine

    Quote Originally Posted by PhHein View Post
    declare two new arrays, one called odd and one called even. Add the numbers accordingly and use them for your output.
    thanks for reply, where should I put the two new arrays? Is in the conditional?

  4. #4
    Aries. is offline Member
    Join Date
    Jan 2013
    Posts
    22
    Rep Power
    0

    Default Re: [Java Eclipse] How to combine

    Quote Originally Posted by laahettien View Post
    ...
    Speak english please :-(


    By the way, problem solved. :-) Thanks for the tips.
    Last edited by doWhile; 02-04-2013 at 06:22 PM. Reason: Removed spam quote

Similar Threads

  1. Replies: 2
    Last Post: 01-01-2012, 06:07 AM
  2. Combine two S.O.P in one
    By javauserjava in forum New To Java
    Replies: 5
    Last Post: 04-05-2011, 06:27 AM
  3. Replies: 1
    Last Post: 08-28-2009, 11:46 AM
  4. How to combine mysql and java?
    By sandeeprao.techno in forum Advanced Java
    Replies: 1
    Last Post: 05-21-2008, 04:41 AM
  5. Combine package of(jdk,eclipse and tomcat)
    By joseph in forum Eclipse
    Replies: 0
    Last Post: 04-07-2008, 01:18 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •