Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Interview-Questions I need to output number diamond using nested for loops.

Have Programming Question? Ask it here!
 
 
 


Jiawei Tan
I need to output number diamond using nested for loops.
1 Answer(s)      3 years and 2 months ago
Posted in : Java Interview Questions


How to i output this using nested for loops

    1
   131
  13531
 1357531
135797531
 1357531
  13531
   131
    1

Advertisement
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
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.
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
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
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 program to insert data in database using javascript
i need program to insert data in database using javascript  please help me
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
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...; sortedArray.length; i++){ count++; } document.write("Number
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
loops
loops  I need the program output 55555 4444 333 22 1 like this by using for loop and if condition only
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/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
Nested If Statement
. Here we are providing you an example using Nested-If statement. In the example, we... Nested If Statement       In this section you will study about the Nested-if Statement in jsp
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
Write a program that (algorithmically) shows a times table.(convert integers to strings, format text, nested loops)
Write a program that (algorithmically) shows a times table.(convert integers to strings, format text, nested loops)   Write a java program..., nested loops) 0 1 2 3 4 5 6 7 8 9 0 0 0 0 0 0 0
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
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
Diamond shape num - Java Interview Questions
Diamond shape num  How To Print Diamond Shape Numbers I Want Logic?Using For loops?  Hi Friend, Try the following code: public class Diamond{ public static void main(String[] args){ int row = 5; for(int i=1
print 100 numbers using loops
print 100 numbers using loops  how to print from 1 to 100 using...{ public static void main(String[] args){ for(int i=1;i<=100;i++){ System.out.println(i); } } } Thanks   Hi Friend
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
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
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 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
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
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 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
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
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
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...; int numberOfScores ; // number of scores entered by the user .. int Scores
Loops
Loops  Write code 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
Draw a diamond - Java Beginners
Draw a diamond  I want to draw a diamond shapein java using (*) in 9 lines. Here is the code import java.util.*; public class Diamond { static... the number of star lines and number of blanks"); noOfstarlines=console.nextInt
loops
loops  how to use for loop and while loop in java?/ how to write a code using for or while loop
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
print a-z, A-Z with exact order using loops
print a-z, A-Z with exact order using loops  how to print from a-z, A-Z with exact order using for loop? Thanks for all concern
write program have product - using loops
write program have product - using loops  Write a program...(list3); double sum=0; for(int i=0;i<list3.size();i++){ sum+=Double.parseDouble(list3.get(i).toString()); } System.out.println("The most
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
diamond print
diamond print   print the pattern 1 2 3 4 5 6 7 8 9 10 11 12
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 a 10 digit number using random number and display the length of longest increasing series
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
 

 

 

DMCA.com