🌙 DARK

Hollow Pyramid Pattern

 

Hollow Pyramid
 

The much-awaited event in the entertainment industry every year is the "Screen Awards". This year the event is going to be organized on December 25th to honor the Artists for their professional excellence in Cinema. The Organizers of the event, J&R Events, decided to design attractive LED Matrix panel boards for the show promotions all across the venue.
 
The event organizers wanted to program the display boards with some specific patterns using alphabets and special characters.  Write a program to design the pattern of a hollow pyramid in the matrix panel, given the number of lines of the pattern.


 
Input Format:

The first line of the input is an integer that refers to the number of lines in the pattern.

Output Format:

Output the pattern as given in the output.
Refer sample input and output for formatting specifications.

 

[All text in bold corresponds to input and the rest corresponds to the output.]


Sample Input and Output 1:

4
bbb*bbb
bb*i*bb
b*iii*b
*******

 

Explanation:

The number of characters in the first line is 2*4(input) – 1.

Character ‘b’ occurrence is symmetrical about the center character.

Sample Input and Output 2:

5
bbbb*bbbb
bbb*i*bbb
bb*iii*bb
b*iiiii*b
*********


PROGRAM:-
@MRProgrammer89 


CREATE CLASS < Main :

import java.util.Scanner;

class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        

        int temp = 2*n-1;

        

        for(int i = temp-1;i>=0;i--)

        {

            if(i==(temp-1)/2)

                System.out.print("*");

            else

                System.out.print("b");

        }

        int p=2,temp1=(temp-1)-2;

        System.out.println();

        for(int i=temp1;i>0;i=i-2)

        {

            for(int j=0;j<=i;j++)

            {

                if(j==i/2)

                {

                    System.out.print("*");

                    for(int k=1;k<p;k++)

                        System.out.print("i");

                    System.out.print("*");

                }

                else

                    System.out.print("b");

            }

            p = p+2;

            System.out.println();

        }

        

        for(int i=temp;i>0;i--)

            System.out.print("*");

     }

}


Question 2)


Lucky Pairs
 

Richie and Raechal are participating in a game called "Lucky pairs" at the Annual Game Fair in their Company. As per the rules of the contest, two members form a team and Richie initially has the number A and Raechal has the number B.
There are a total of N turns in the game, and Richie and Raechal alternatively take turns. In each turn, the player's number is multiplied by 2. Richie has the first turn. Suppose after the entire N turns, Richie’s number has become C, and Raechal’s number has become D, the final score of the team will be the sum of the scores (C+D) of both the players after N turns.
 
Write a program to facilitate the quiz organizers to find the final scores of the team.

 
Input and Output Format:

The only line of input contains 3 integers AB, and N.
Output a single line that contains the integer that gives the final score of the team which will be the sum of the scores of both the players after N turns.
Refer sample input and output for formatting specifications.

Sample Input 1:
1 2 1
Sample Output 1:

4

Sample Input 2:
3 7 2

Sample Output 2:
20


PROGRAM:-
@MRProgrammer89 


CREATE CLASS < Main :


import java.util.Scanner;


public class Main{

    public static void main(String[] args){         

       int a, b, n, g;

    Scanner sc = new Scanner(System.in);

System.out.print(" ");

a = sc.nextInt();

System.out.print(" ");

b = sc.nextInt();

System.out.print(" ");

n = sc.nextInt();

for(int i = 0; i < n; i++) {

if(i % 2 == 0) {

a = a * 2;

} else {

b = b * 2;

}

}

g = a + b;

System.out.print(g);

        


}

}


@MRProgrammer89 






MOTIVATION :


    “The way we spend our time defines who we are 


Although we may not see each other as often as we’d like, distance is no match for the bond that we share. Thank you for coming to visit. It was fantastic to catch up.


VISITE MORE BLOGS




THANK YOU....😊


Post a Comment

Thanks for reading the blog. We hope it was useful to you and that you learned something new. Will always be writing on new and interesting topics, so you can visit our website to know the latest updates of our blogs. Thank You!

Previous Post Next Post

Contact Form