Skip to main content

Print Pattern in Java (Part 13)

> Write a program to print following pattern:

Z
Z Y
Z Y X
Z Y X W
Z Y X W V
view raw test.txt hosted with ❤ by GitHub
Solution:
import java.util.Scanner;
class pattern
{
public static void main(String ar[])
{
Scanner scan = new Scanner(System.in);
System.out.println("Enter the limit or number of lines");
int limit = scan.nextInt();
int value = 90;
int space = limit-1;
for(int i=1; i<=limit; i++){
for(int k=space; k>=1; k--){
System.out.print(" ");
}
for(int j=1; j<=i; j++){
System.out.print((char)value+" ");
value--;
}
System.out.println();
space--;
value=90;
}
}
}
view raw pattern.java hosted with ❤ by GitHub

Comments

  1. Hi, thanks for your blog, if you want to learn about programming languages like java, php, android app, embedded system etc. I think this training institute is the best one.
    Best java training in coimbatore
    Android training in coimbatore
    Networking training in coimbatore

    ReplyDelete
  2. Grab the astounding Azure Training in Chennai along with the best DevOps Training and Java training from Infycle Technologies, the best software training institute in Chennai. Call 7504633633 to get the best placement guidance along with the software training for having a lucrative career in the software industry

    ReplyDelete

Post a Comment

Relevant to YOU:

Popular posts from this blog

ASCII Code in Java (Part 1)

> The ASCII Code: (Part 1) ASCII stands for "American Standard Code for Information Interchange". As you may remember (Grade 9), computers only work with HIGH(1) and LOW(0) electrical states, known as bits, with correspond to mathematical Base 2 numbers. That is, computers only understand binary language. ASCII codes represent text (or other things) in computers. Assume that you are working with MS Word, or PPT or any other tool that uses text based inputs from user. You need to type a sentence that computer is not aware of. ASCII codes help to exchange this information between user and computer. When you type a character, it is converted into ASCII code first and then into Binary, which makes the computer understand what is to be typed. Hence every key on the keyboard has a specific ASCII code which is used to make the computer understand our language. If you press 4 from keyboard, then keyboard send the value 100 (value equival...

Character Class in Java (Part 2)

> The Character Class: (Part 1) Methods of Character class: Example: Method -> isDigit() [validating name] Example: Method -> isLetter() [validating mobile number] Example: Method -> isLetterOrDigit() [validating user_id / username] Example: Method -> isLowerCase() Example: Method -> isUpperCase() Example: Method -> toUpperCase() and toLowerCase() Click HERE for the list of Methods of Character class. Click HERE for the ASCII Table for different Characters