Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Programming Java Help

  • 13-01-2009 7:28pm
    #1
    Closed Accounts Posts: 1


    can anybody help me quickly
    this my code for java
    when run for example input = 3 you get the following output
    ***
    **
    *
    what i need is this
    *
    **
    ***
    **
    *

    this is a matter of urgency my email is sipod06@hotmail.com

    my code

    import java.util.Scanner;

    //prints a triangle of *s, as wide as the user specifies
    public class Document1
    {
    public static void main(String[] args)
    {
    Scanner in = new Scanner(System.in);

    //prompts user to input a number
    System.out.print("Please input a number: ");
    //saves the user's number into n
    int n = in.nextInt();
    //declares row variable
    int row;

    while (n > 0)
    {
    row = n;
    while (row > 0)
    {
    //prints the * character
    System.out.print("*");
    //decrements row
    row--;
    }
    //goes to the next line
    System.out.println();
    //decrement n
    n--;
    }
    }
    }
    Tagged:


Comments

  • Registered Users, Registered Users 2 Posts: 1,119 ✭✭✭Donald-Duck


    Have it print from 0 to n-1 before printing from n to 0


  • Registered Users, Registered Users 2 Posts: 61 ✭✭GavinJCD


    I think you should go back to the IMACD's there Simon, you won't be programming the new windows anytime soon, they would have to rename it to Winblows. Or windows Vista the second coming.

    Either way, I can see a lot of forms in your future. Oh yeh and Aillin says hi.


  • Registered Users, Registered Users 2 Posts: 17,727 ✭✭✭✭Sherifu


    Using for loops would probably be easier on the eye, that and using Donald-Duck's advice.


Advertisement