Hurry help me

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Aug 2009
Posts: 5
Reputation: Master Piece is an unknown quantity at this point 
Solved Threads: 0
Master Piece Master Piece is offline Offline
Newbie Poster

Hurry help me

 
0
  #1
Aug 23rd, 2009
how can i print a triangle in java.Its shape is like this
A
B C
D E F
G H I J
K L M N O
i have to use ascii code for printing alphabets.
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 232
Reputation: sravan953 has a little shameless behaviour in the past 
Solved Threads: 28
sravan953's Avatar
sravan953 sravan953 is offline Offline
Posting Whiz in Training

Re: Hurry help me

 
-3
  #2
Aug 23rd, 2009
Try this, it should work:
  1. class print_ascii
  2. {
  3. static void ascii()
  4. {
  5. for(int j=1;j<=26;j++)
  6. {
  7. int n=65;
  8. for(int i=1;i<=j;i++)
  9. {
  10. char a=(char)n;
  11. System.out.print(a+" ");
  12. n++;
  13. }
  14. System.out.println();
  15. }
  16. }
  17. }
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 5
Reputation: Master Piece is an unknown quantity at this point 
Solved Threads: 0
Master Piece Master Piece is offline Offline
Newbie Poster

Re: Hurry help me

 
0
  #3
Aug 23rd, 2009
i am new in programming plz tell me,will i have to give a value on runtime??
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 5
Reputation: Master Piece is an unknown quantity at this point 
Solved Threads: 0
Master Piece Master Piece is offline Offline
Newbie Poster

Re: Hurry help me

 
0
  #4
Aug 23rd, 2009
C:\jdk1.3\bin>javac print.java

C:\jdk1.3\bin>java print
Exception in thread "main" java.lang.NoSuchMethodError: main
.This was given by the program
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 5
Reputation: Master Piece is an unknown quantity at this point 
Solved Threads: 0
Master Piece Master Piece is offline Offline
Newbie Poster

Re: Hurry help me

 
0
  #5
Aug 23rd, 2009
thanks i solved this problem.But i have to print till "J" only what should i do.
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 5
Reputation: Master Piece is an unknown quantity at this point 
Solved Threads: 0
Master Piece Master Piece is offline Offline
Newbie Poster

Re: Hurry help me

 
0
  #6
Aug 23rd, 2009
what should i do i have to print till "J" only
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 1,000
Reputation: JamesCherrill is just really nice JamesCherrill is just really nice JamesCherrill is just really nice JamesCherrill is just really nice JamesCherrill is just really nice 
Solved Threads: 147
JamesCherrill JamesCherrill is online now Online
Veteran Poster

Re: Hurry help me

 
0
  #7
Aug 23rd, 2009
Just before you print each letter, check to see if its greater than 'J', if it is, you can exit your program immediately (exit is a method in the System class)
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 50
Reputation: coud_ren_26 has a little shameless behaviour in the past 
Solved Threads: 0
coud_ren_26's Avatar
coud_ren_26 coud_ren_26 is offline Offline
Junior Poster in Training

Re: Hurry help me

 
0
  #8
Aug 24th, 2009
  1. class print_ascii
  2. {
  3. static void ascii()
  4. {
  5. for(int j=1;j<=26;j++)
  6. {
  7. int n=65;
  8. for(int i=1;i<=j;i++)
  9. {
  10. char a=(char)n;
  11. System.out.print(a+" ");
  12. n++;
  13. }
  14. System.out.println();
  15. }
  16. }
  17. }
Last edited by John A; Aug 26th, 2009 at 12:08 am. Reason: added code tags
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 1,000
Reputation: JamesCherrill is just really nice JamesCherrill is just really nice JamesCherrill is just really nice JamesCherrill is just really nice JamesCherrill is just really nice 
Solved Threads: 147
JamesCherrill JamesCherrill is online now Online
Veteran Poster

Re: Hurry help me

 
0
  #9
Aug 24th, 2009
Yes, and... ?
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum
Thread Tools Search this Thread



Tag cloud for Java
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC