I need to output number diamond using nested for loops.

I need to output number diamond using nested for loops.

How to i output this using nested for loops

    1
   131
  13531
 1357531
135797531
 1357531
  13531
   131
    1
View Answers

May 24, 2011 at 4:20 PM

class Pyramid{
public static void main(String[] args){
    for(int row = 1; row <= 5; row++){
for(int col = 4; col >= row; col--){
System.out.print(" ");
}
for(int col2 = 1; col2 <= row*2; col2+=2){
System.out.print(col2);
}
for(int col3 = row*2-3; col3 >= 1; col3-=2){
System.out.print(col3);
}
System.out.println();
   }
   }
  }









Related Tutorials/Questions & Answers:
I need to output number diamond using nested for loops.
I need to output number diamond using nested for loops.  How to i output this using nested for loops 1 131 13531 1357531 135797531 1357531 13531 131 1
Using Nested loops
Using Nested loops  How to use nested loops in java when I want...[][] array = new int[16][16]; for (int i=1; i<array.length; i++) { for (int j=1; j<array[i].length; j++) { array[i][j] = i*j; System.out.print(" " + array[i][j
Advertisements
nested for loops
nested for loops  Hello all, I have created a program(gui... the totals after each entry, when all I need is just a total of all entries. This is my first time using java and my first time programming, but I am guessing
nested loops
nested loops  please tell input to get the output: 12345 23456 34567 45678
Need help with nested queries
Need help with nested queries  Hello, Table1 has "id", "votes" columns. Table2 has "id", "Name" column. I need to retrieve Name and its corresponging Votes. I tried with nested queries but its confusing. Can anyone please help
pattern-using loops
pattern-using loops  Write a program that displays the following pattern ... (use nested loops... A { public static void main(String[] args) { for(int i=0;i<5;i
Nested Ajax--not getting output
Nested Ajax--not getting output  Hi everyone... I have two.jsp page from that , with the help of ajax i have called three.jsp. So, i have used DIV... time running...when i run One.jsp , with the help of ajax when i call two.jsp.
i need program to insert data in database using javascript
i need program to insert data in database using javascript  please help me
read string - using loops in Java
read string - using loops in Java  Write a program to read a string composed of an unknown number of words, then count the number of words in the string, and Display the longest and shortest words, with first letter Uppercase
i need to print customer[1] is abcd,cbnb using array
i need to print customer[1] is abcd,cbnb using array  print("code...) { int i=noofcustomers++; customers[i]=new Customer(f,l); } public..."); System.out.println( b.getnoofcustomers()); for(int i=0;i<5;i++) { System.out.println
i need to print customer[1] is abcd,cbnb using array
i need to print customer[1] is abcd,cbnb using array  print("code...) { int i=noofcustomers++; customers[i]=new Customer(f,l); } public..."); System.out.println( b.getnoofcustomers()); for(int i=0;i<5;i++) { System.out.println
i need to print customer[1] is abcd,cbnb using array
i need to print customer[1] is abcd,cbnb using array  print("code...) { int i=noofcustomers++; customers[i]=new Customer(f,l); } public..."); System.out.println( b.getnoofcustomers()); for(int i=0;i<5;i++) { System.out.println
i need to print customer[1] is abcd,cbnb using array
i need to print customer[1] is abcd,cbnb using array  print("code...) { int i=noofcustomers++; customers[i]=new Customer(f,l); } public..."); System.out.println( b.getnoofcustomers()); for(int i=0;i<5;i++) { System.out.println
Loops
Loops  by using drjava q1.Write code that uses nested loops to print... that ask user to insert an integer (n) and prints out the factorial (n!) of this number. n! = n (n-1)(n-2)(n-3)ââ?¬Â¦Ã¢â?¬Â¦Ã¢â?¬Â¦1 , n > 0 plzz i need
i want to do a project using jsp and servlet....What are all the materials i need to study
i want to do a project using jsp and servlet....What are all the materials i need to study   i want to do a project using jsp and servlet....What are all the materials i need to study ?   Please visit the following
i need a school appication using struts frame work with oracle 10g using myeclipse6.0
i need a school appication using struts frame work with oracle 10g using myeclipse6.0   hi i need a school apllication using struts frame work backend 10g xe using myeclipse 6.0
Solve using only Javascript loops...
Solve using only Javascript loops...  Write a JavaScript code, 1) to find a number of unique letters in string. (Eg. if keyword is unique, Unique... display the complete date, including the correct extension on the day number
loops
loops  I need the program output 55555 4444 333 22 1 like this by using for loop and if condition only
i need a help in this please
i need a help in this please  The factorial of a nonnegative integer...) Write an application that computes the value of ex by using the formula ex = 1...=new Scanner(System.in); System.out.print("Enter Number: "); int m
How do i get the number of online users from a site using jsp?
How do i get the number of online users from a site using jsp?  Hi, Can any one tell me how to get the number of records from a database dynamically, when each person got logged into the page in jsp
I need an example of sessionfactory
I need an example of sessionfactory  Hi, I need an example of session factory in hibernate. If you can provide me one with, that would be great...Thanks
I/O Program output error
I/O Program output error  Hello All, I am working on a program... file, but I am getting incorrect output. I have been successfull with part of the program in that it reads the text file and analyzes it, however I need it to take
i need help plz .... Quickly
i need help plz .... Quickly   how can i count how many numbers enterd by the user so the output would be like this Total number of Scores... numberOfScores ; // number of scores entered by the user .. int Scores;//scores
Java repeat string without using loops
Java repeat string without using loops In this section, you will learn how to repeat string without using for loops. The given example accepts the number of times and iterates the string to the number of times set by the user without
Creating custom output using XMLUnit - MatchTracker duplicates the output data
Creating custom output using XMLUnit - MatchTracker duplicates the output data  how to create a custom output using xmlunit, I have tried it and used... in input xml and I am having duplicate data in output
Loops
Loops  ï??Using for loops, Write a program to simulate a clock countdown. The program prompts the user to enter the number of seconds, displays... System.currentTimeMillis() which return the number of milliseconds since the epoch
Java reverse words in a string using only loops
Java reverse words in a string using only loops In this tutorial, you will learn how to reverse words in a string without using any inbuilt methods like split() etc, StringTokenizer functiom or any extra ordinary function Only loops
i need project
i need project  can u send online shoppin project 2 my mailid.   Please visit the following links: Struts2 Shopping cart JSP-Servlet Shopping cart
hello there i need help
hello there i need help  : i need to do a program like this: Automatic Teller Machine [B] Balance [D] Deposit [W] Withdrawal [Q] Quit select you... me with the codes and please explain to me how it works. i only need to use
print rectangle triangle with ?*? using loops
print rectangle triangle with ?*? using loops   * * * * * * i want print like this.what is the code?   import java.lang.*; class Traingles { public static void main(String args[]) { for(int i=1;i<=5
print 100 numbers using loops
print 100 numbers using loops  how to print from 1 to 100 using... class Loop{ public static void main(String[] args){ for(int i=1;i<=100;i++){ System.out.println(i); } } } Thanks  
I have need to help
I have need to help  Write a program that, for four points A, B, C and P, draws a triangle formed by ABC and a small cross showing the position of P; and displays a line of text indicating which of the following three cases
output using SQL
output using SQL  how to get ( 15 march 2011) and (15/03/2011) output using SQL   Use the following queries to get the data from database in the given format. For (15 march 2011) format: SELECT DATE_FORMAT(dob, '%d
Nested If Statement
if statement. Here we are providing you an example using Nested-If statement...>Nested if Statement Example</H2> <% double number = 4... Nested If Statement      
using random number
using random number  generate a 10 digit number using random number and display the length of longest increasing series
I need Spring 2.5 example.
I need Spring 2.5 example.  Hello, I am looking forward to learn Spring framework and hence I need Spring 2.5 and Spring 3.0 example.. Thanks
Loops
Loops  Write code that uses nested loops to print the following patterns: Pattern1: 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 1 2 3 4 5 6 Pattern 2: 1 2 3 4 5 6 1 2 3 4 5 1 2 3 4 1 2 3 1 2 1
Loops
Loops  Write code that uses nested loops to print the following patterns: Pattern1: 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 1 2 3 4 5 6 Pattern 2: 1 2 3 4 5 6 1 2 3 4 5 1 2 3 4 1 2 3 1 2 1
This is what i need - Java Beginners
. for this question i need just : one function can read string like (I like...This is what i need  Implement a standalone procedure to read... in an output file. The compressed version should contain all of the words
using random number
using random number  generate 10 number and display the length of longest incresing series
using random number
using random number  generate 10 digit number and display the length of longest incresing swries
I need to develop a gui like this
I need to develop a gui like this  Hai Friends, I need to develop such a menu in my gui programs. The gui contains 1 text field.whenever the text... please help me   sorry goes through this link I need to develop like
i need program or code for this program
i need program or code for this program  out should be in this form 1 2 3 4 5 6 3 5 7 9 11 8 12 16 20 20 28 36 48 64 112
PLZ HELP ME. i need php code.
PLZ HELP ME. i need php code.   I want php code for bellow OUTPUT. output is just example but it must be letters only. abc bcd efg jku rgt azs hje qqc wws adt
i need a java code for finding typemismatch in an editor.
i need a java code for finding typemismatch in an editor.  hi im sriram, i need a java code in such a way that typemismatch code is embedded with the simple java editor. the sample output is shown below !alt text
i need help - Development process
i need help  hello, i need help regarding this program. public...()); } } } it is printing the result of ping in to a file,but if i want... the result in to the files,if i want to do this i must make my program running
printing the following output using for loop
printing the following output using for loop  1 2 3 3 4 5 4 5 6 7
printing the following output using for loop
printing the following output using for loop  1 2 3 3 4 5 4 5 6 7
loops
loops  how to get the sum of 10 number using a loop
i need help to solve this problem
i need help to solve this problem  Write a stack class ArrayStack.java implements PureStack interface that reads in strings from standard input.... H and I join the queue h. G leaves the queue i. H and I leave the queue

Ads