5th sem OOPJ Write an interactive program to print a string entered in a pyramid form. For instance, the string “stream” has to be displayed as follows.


import java.util.Scanner;

/**
 *
 * @author Yash
 */

public class pra9 {
    public static void main(String arg[]){
        char c;
        int i,j,k;
        Scanner sc = new Scanner(System.in);
        String s1;
        System.out.print("Enter the String :");
        s1=sc.next();
        for(i=0;i<s1.length();i++){
            for(j=0;j<=s1.length()-i;j++){
                System.out.print(" ");
            }
            for(k=0;k<=i;k++){
                c = s1.charAt(k);
                System.out.print(c+" ");
            }
            System.out.println(" ");
        }
    }
}

Comments

Popular posts from this blog

5th sem OOPJ Write a program that calculates percentage marks of the student if marks of 6 subjects are given.

Javascript Lab 2

5th sem OOPJ Create a class called Student. Write a student manager program to manipulate the student information from files by using DataInputStream and DataOutputStream.