Welcome to Dream.In.Code
Become a Java Expert!

Join 150,041 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,599 people online right now. Registration is fast and FREE... Join Now!




triangle base question

 
Reply to this topicStart new topic

triangle base question

divya malhotra
15 Jun, 2008 - 12:16 AM
Post #1

New D.I.C Head
*

Joined: 14 Jun, 2008
Posts: 3

*
* *
* * *
* * * *
* * * * *
can you pls tel me the programm code to display this series??
User is offlineProfile CardPM
+Quote Post

mensahero
RE: Triangle Base Question
15 Jun, 2008 - 12:59 AM
Post #2

c0mput3rz Are Only Human
Group Icon

Joined: 26 May, 2008
Posts: 664



Thanked: 17 times
Dream Kudos: 75
My Contributions
Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Please post like this:

Thank you for helping us helping you.

If you search the forum there is a thread that could help you with that but its not the exact code. Still you can learn from it.
User is offlineProfile CardPM
+Quote Post

neotrumatrix
RE: Triangle Base Question
15 Jun, 2008 - 03:58 AM
Post #3

New D.I.C Head
Group Icon

Joined: 6 Oct, 2005
Posts: 49



Thanked: 3 times
Dream Kudos: 50
My Contributions
QUOTE(mensahero @ 15 Jun, 2008 - 01:59 AM) *

If you search the forum there is a thread that could help you with that but its not the exact code. Still you can learn from it.


A recent thread has similar question with code ... So either you write your code and help use debug it or search through the posts tongue.gif

User is offlineProfile CardPM
+Quote Post

cutegrrl
RE: Triangle Base Question
15 Jun, 2008 - 02:26 PM
Post #4

D.I.C Head
**

Joined: 12 May, 2008
Posts: 72



Thanked: 7 times
My Contributions
java

import java.io.*;

public class Foo {

// Create a single shared BufferedReader for keyboard input
private static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

// Program exectuon starts here
public static void main(String args[]){

// Loop until valid input is entered
while(true){
try{
// Prompt user for input
System.out.print("Enter height of triangle: ");
int height = Integer.parseInt(in.readLine());
if(height > 0){
// Print triangle
for(int i = 1; i <= height; i++){
for(int j = 1; j <= i; j++){
System.out.print("* ");
}
System.out.println();
}
break;
}else{
System.out.println("Invalid input. Please enter a positive value.");
}
}catch(Exception e){
System.out.println("Invalid input. Please enter a valid number.");
}
}
}

}


This post has been edited by cutegrrl: 15 Jun, 2008 - 02:27 PM
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 09:51PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month