Results 1 to 5 of 5
Like Tree1Likes
  • 1 Post By Norm

Thread: Making XOXO from input

  1. #1
    knight4d is offline Member
    Join Date
    Nov 2016
    Posts
    3
    Rep Power
    0

    Question Making XOXO from input

    bro i want to make a program that have output like this :

    input number : 5
    xooox
    oxoxo
    ooxoo
    oxoxo
    xooox

    anyone can help me ?

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: Making XOXO from input

    anyone can help me ?
    What have you tried?
    Post your code wrapped in code tags and the program's current output.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    knight4d is offline Member
    Join Date
    Nov 2016
    Posts
    3
    Rep Power
    0

    Default Re: Making XOXO from input

    Java Code
    Java Code:
    import java.util.Scanner;
    public class Main {
        public static void main(String[] args) {
            Scanner input=new Scanner (System.in);
            System.out.print("Input number : ");
            int number=input.nextInt();
            for(int k=1; k<=number ;k++){ 
            if(k%2==0) System.out.print("O");
            else System.out.print("X");
        }
            System.out.println("");
            for(int k=1; k<=number ;k++){ 
            if(k%2!=0) System.out.print("O");
            else System.out.print("X");
            } System.out.println("");
            
            for(int k=1; k<=number ;k++){ 
            if(k%2==0) System.out.print("O");
            else System.out.print("X");}
            
            System.out.println("");
            for(int k=1; k<=number ;k++){ 
            if(k%2!=0) System.out.print("O");
            else System.out.print("X");
            } System.out.println("");
            
            for(int k=1; k<=number ;k++){ 
            if(k%2==0) System.out.print("O");
            else System.out.print("X");
        } System.out.println("");
    output:
    Input number : 5
    XOXOX
    OXOXO
    XOXOX
    OXOXO
    XOXOX
    [/QUOTE]
    i want to fix the 1st,3rd,and 5th line
    i dont know how to connect the logic ..
    Last edited by Norm; 11-12-2016 at 02:31 PM. Reason: quote tags changed to code tags

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: Making XOXO from input

    how to connect the logic
    Start by describing what should be printed on each line and how what is printed is related to what line is being printed.
    How does the column being printed relate to what should be printed?

    The code's formatting needs to be fixed. The } should be in the same column as the start of line with the {
    Logically nested statements need to be indented to show the nesting. For example:
    Java Code:
       for(the controls) {
          // this is nested
       }  // below for
    Last edited by Norm; 11-12-2016 at 02:33 PM.
    knight4d likes this.
    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    knight4d is offline Member
    Join Date
    Nov 2016
    Posts
    3
    Rep Power
    0

    Cool Re: Making XOXO from input

    Quote Originally Posted by Norm View Post
    Start by describing what should be printed on each line and how what is printed is related to what line is being printed.
    How does the column being printed relate to what should be printed?

    The code's formatting needs to be fixed. The } should be in the same column as the start of line with the {
    Logically nested statements need to be indented to show the nesting. For example:
    Java Code:
       for(the controls) {
          // this is nested
       }  // below for
    thanks bro .. its all done :D

Similar Threads

  1. Replies: 6
    Last Post: 12-26-2012, 11:24 PM
  2. Replies: 9
    Last Post: 05-11-2011, 07:12 PM
  3. Replies: 2
    Last Post: 01-13-2011, 06:43 AM
  4. Making arrays by reading user input
    By apfroggy0408 in forum New To Java
    Replies: 23
    Last Post: 04-30-2008, 02:23 AM
  5. Heyyy.............xoxo
    By Amy in forum Introductions
    Replies: 3
    Last Post: 12-24-2007, 05:07 AM

Posting Permissions

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