Question

Question 9: Write a program to create the following figure by using of nested for loops. Please assign the number of lines asProgramaming language is java

just need the code

0 0
Add a comment Improve this question Transcribed image text
Answer #1

9). ANSWER :

GIVENTHAT :

CODE:

import java.util.Scanner;

public class Pyramid {

   public static void printPyramid(int n)
{
  
       int i, sp, k=0;
  
  
for(i=1; i<=n; i++)
{
for(sp=1; sp<=(n-i); sp++)
{
System.out.print(" ");
}
while(k != (2*i-1))
{
System.out.print("*");
k++;
}
k = 0;
System.out.println();
}
}
   public static void main(String[] args) {
       Scanner scan = new Scanner(System.in);
System.out.print("Enter the segment and height : ");
  
  
int seg=scan.nextInt();
int height = scan.nextInt();
System.out.println("SEGMENT = "+seg+" and "+" HIGHT = "+height);
for(int i=0;i<seg;i++) {
   printPyramid(height);
}
  
   }

}

The above program OUTPUT :

Enter the segment and height : 34 SEGMENT = 3 and HIGHT = 4 来来来 来来来来来 $$$$$$$ 常常来 来来来来来 米米米米米米米 $$$ 来来来来来

Enter the segment and height : 26 SEGMENT 2 and HIGHT = 6 * *** 来来来来来 》》》》》》》 来来来来来来来来 来来来来来来来来来来来 来来来 米米米 $$$$$$$ 来来来来来来来来来

Add a comment
Know the answer?
Add Answer to:
Programaming language is java just need the code Question 9: Write a program to create the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Use the GPen class to create a work of art. THIS IS JAVA language . anything...

    Use the GPen class to create a work of art. THIS IS JAVA language . anything good Requirements Programs should be at least 20 lines of code, not including comments and white space. Include a block comment header at the top of your program. Comment your program! If you add a segment of code that draws an object or performs an action, place a comment at the top. You should only being using GPen to draw your work of art

  • Code a Java program to create and use OO classes. Comment your code throughout. Create a...

    Code a Java program to create and use OO classes. Comment your code throughout. Create a Super class named Home Properties address SF (this is the number of Square feet) value (this is the dollar value of the home) Methods Set and get methods for all properties calcValue() - calculate the value as sf * 400 displayCondo() - displays all properties of a condo Create a sub class named Condo Properties HOAfee (home owners association fee) Methods Set and get...

  • This program needs to be in JAVA language. Also, I need to create my own LinkedList...

    This program needs to be in JAVA language. Also, I need to create my own LinkedList class, I can not use the Java LinkedList Library. Please read all aspects of the program, it needs to display 200 random numbers that are 5 digits long sorted from smallest to largest. I can not use Collection(s) or packages libraries. Should only need: import java.util.Random; import java.util.Scanner; Please provide output screenshots after the code. Thank you! You are going to create a Linked...

  • Write a program for the management of a bookstore in Java Programming Language, WITHOUT THE USE...

    Write a program for the management of a bookstore in Java Programming Language, WITHOUT THE USE OF STUFF RELATING TO OBJECTS AND WHAT NOT, just arrays, strings, loops, etc. I'm in an intro to programming class so I haven't learned those techniques and am not allowed to use them. The books we just create Overview; Opening menu 1. List all books 2. Search all books 3. Purchase books 4. Exit If option 1 is chosen: List all books by Title,...

  • Homework description::::: Write JAVA program with following description. Sample output with code will be helful... A...

    Homework description::::: Write JAVA program with following description. Sample output with code will be helful... A compiler must examine tokens in a program and decide whether they are reserved words in the Java language, or identifiers defined by the user. Design a program that reads a Java program and makes a list of all the identifiers along with the number of occurrences of each identifier in the source code. To do this, you should make use of a dictionary. The...

  • Need to write the program.. In java language. And That the program should be according to...

    Need to write the program.. In java language. And That the program should be according to given scenario.. You need to design and implement the following structure for your organization. You must follow the instructions given below 1 - Name of you organization is your surname. For example, if your name is "Qasim Ali", then "Ali" will be organization name. 2- Organization and Person must be interfaces. 3 - Staff and infrastructure must be abstract classes. 4 - Rest of...

  • Hi I need help creating a program in JAVA. This is material from chapter 9 Objects...

    Hi I need help creating a program in JAVA. This is material from chapter 9 Objects and Classes from the Intro to JAVA textbook. Mrs. Quackenbush's Rent-A-Wreck car rental ..... Mrs. Q asked you to create a program that can help her track her growing fleet of junkers. Of course she expects you to use your best programming skills, including: 1. Plan and design what attributes/actions an automobile in a rental fleet should have (example. Track number of Trucks, SUVs,...

  • his assignment will help the student by: Create shapes using Java code Using and creating colors...

    his assignment will help the student by: Create shapes using Java code Using and creating colors with Java Coding JFrames and using the Graphics g method Using Loops (to draw) Your program will generate a drawing using java. You should draw an object that makes sense, not just spare shapes and colors. You must use at least 3 different shapes You must use at least 2 different fonts You must use at least 2 predefined java colors and one custom-made...

  • Need Help Please Using Java Language Create a Code Write a class (and a client class...

    Need Help Please Using Java Language Create a Code Write a class (and a client class to test it) that encapsulates the evolution of the passwords of three students over four months. Your only instance variable should be a two-dimensional array of values representing the passwords. Dimension 1 represents the student and dimension 2 represents the month. (Since we are concerned about security, we are assuming that people change their password once a month; we only care about the value...

  • Please help me to solve this problem with java language! write a program that runs a...

    Please help me to solve this problem with java language! write a program that runs a thread which prints a timestamp and then waits a second by doing the following: 1. Implement a class that implements the Runnable interface. (1 point) 2. Place the code for your task into the run method of your class. (6 points) a) To get the date and time, construct a Date object. b) To wait a second, use the sleep method of the Thread...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT