Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > General Coding
You last visited: Today at 19:43

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



How do i do this output in JAVA ??

Discussion on How do i do this output in JAVA ?? within the General Coding forum part of the Coders Den category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Dec 2009
Posts: 12
Received Thanks: 0
How do i do this output in JAVA ??

How do i do this kind of program in java?

Enter a Number: 5

*
**
***
****
*****
****
***
**
*
Process Completed.
zepolzirk is offline  
Old 09/26/2011, 08:33   #2
 
Kinu's Avatar
 
elite*gold: 10
Join Date: May 2006
Posts: 2,786
Received Thanks: 773
There is a coding section for this

Kinu is offline  
Old 09/26/2011, 10:05   #3
 
elite*gold: 14
The Black Market: 108/0/1
Join Date: May 2011
Posts: 2,671
Received Thanks: 818
System.out.printf("*");
vwap is offline  
Old 09/26/2011, 22:35   #4
 
XxharCs's Avatar
 
elite*gold: 34
Join Date: Apr 2011
Posts: 1,475
Received Thanks: 1,228
Maybe something like this :O
Code:
public class Stars{ 
	char star = '*'; 
	char[][]st; 

	public Stars(int cnl1) { 
		st = new char [cn1][cn1]; 
	       for (int i=0; i < cnl1;i++) 
	    	   for (int j = 0; j <cn 1;j++) 
	    		   st [i][j] =star ;
	} 
          

	void starsShow() { 
	     for (int i=0; i < st.length;i++) 
	    	 for (int j = 0; j < st.length;j++){ 
	    		 System.out.print(st[i][j]);
	    		 if(j==st.length-1)
		    		 System.out.println("");
	    	 }
	} 
}
Not sure if you will get something like this(1 year has past when i done such programms in school, so i am not sure^^):
*
**
***
****
*****
****
***
**
*
XxharCs is offline  
Old 09/27/2011, 01:52   #5
 
elite*gold: 0
Join Date: Jul 2010
Posts: 388
Received Thanks: 196
Code:
void stars(int n)
{
    String st = new String();
    for(int i = 0; i < n; i++)
    {
        System.out.println(st+="*");
    }
    for(int i = 1; i < n; i++)
    {
        System.out.println(st.substring(i, n));
    }
}
SmackJew is offline  
Old 09/27/2011, 11:19   #6
 
link's Avatar
 
elite*gold: 1
Join Date: Jul 2005
Posts: 553
Received Thanks: 454
Code:
public class Test
{
    public static void main(String[] args)
    {
        System.out.println(">");
        System.out.println(Lines(9));
        System.out.println("-");
        System.out.println(Amount(5));
        System.out.println("<");
    }

    public static String Lines(int lines)
    {
        String str = new String();
        lines |= 1;
        for (int i = 0; i < lines; i++)
        {
            if (i > 0)
            {
                str += "\n";
            }
            for (int j = 0; j < ((i > lines / 2) ? lines - i : i + 1); j++)
            {
                str += "*";
            }
        }
        return str;
    }

    public static String Amount(int amount)
    {
        return Lines((amount & ~1) * 2 + 1);
    }
}
link is offline  
Reply


Similar Threads Similar Threads
[JAVA Error] Could not create the java virtual machine
07/21/2013 - Technical Support - 10 Replies
Schönen Abend! Leider hat es sich aus einem unerfindlichen Grund ergeben, dass sobald ich die Minecraft.exe starten will die Errormeldung kommt. Die Tips auf Minecraft.net habe ich schon ohne Erfolg befolgt. Hoffe ihr könnt mir weiterhelfen... Mein PC:
[Java] Could not create the Java virtual machine
06/22/2011 - Minecraft - 1 Replies
hallo ihr minecraftler ^^ habe seit heute das problem das wenn ich minecraft starte original als auch cracked das diese fehlermeldung kommt: Java virtual machine Launcher Could not create the Java virtual machine
Output Level
02/26/2011 - General Art - 3 Replies
Hallo, Ich habe eine frage Wo finde ich in Photoshop CS5 das Output level bzw. wo kann ich dieses ändern ?!!



All times are GMT +1. The time now is 19:43.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.