/**
* Prints a pyramid of asterisks of the specified height.
*
* Will print in the form: printStars(3) =
*
***
*****
*/
public static final void printStars(final int height) {
// perform calculations once
final int totalLength = (height * 2) - 1;
final int totalLength_2 = totalLength / 2;
StringBuilder str = new StringBuilder(totalLength);
// fill with spaces
for (int i = 0; i < totalLength; ++i) {
str.append(' ');
}
// fill in levels
for (int i = 0; i <= totalLength_2; ++i) {
str.setCharAt(totalLength_2 + i, '*');
str.setCharAt(totalLength_2 - i, '*');
System.out.println(str);
}
}
/**
* Prints a pyramid of asterisks of the specified height.
*
* Will print in the form: printStars(3) =
*
* *
* *
*/
public static final void printStars(final int height) {
// perform calculations once
final int totalLength = (height * 2) - 1;
final int totalLength_2 = totalLength / 2;
StringBuilder str = new StringBuilder(totalLength);
// fill with spaces
for (int i = 0; i < totalLength; ++i) {
str.append(' ');
}
// fill in levels
for (int i = 0; i <= totalLength_2; ++i) {
if ((totalLength_2 + i - 1) >= 0) {
str.setCharAt(totalLength_2 + i - 1, ' ');
}
if ((totalLength_2 - i + 1) < totalLength) {
str.setCharAt(totalLength_2 - i + 1, ' ');
}
str.setCharAt(totalLength_2 + i, '*');
str.setCharAt(totalLength_2 - i, '*');
System.out.println(str);
}
} OR second method and easier package javaapplication12; /**
*
* @author Dexy86
*/
public class Main {
public static void main(String[] args) {
for(int i=0; i<5; i++){
for(int v=0;v<i; v++){
System.out.print("*");
}
System.out.println();
}
}
}
Here's a simple Python program that constructs and displays a pyramid: def print_pyramid(height): for i in range(height): print(' ' * (height - i - 1) + '*' * (2 * i + 1)) print_pyramid(5) This code defines a function print_pyramid that takes the height of the pyramid as an argument and prints a pyramid made of asterisks (*). Adjust the height parameter in the print_pyramid function call to change the size of the pyramid.
i want to write a simple without using pointer or array c program which will print greatest number when i give 20 number .........How far have you gotten so far?
The Java pattern program ABCDE typically involves printing the letters A, B, C, D, and E in a specific format. A common implementation is to print each letter on a new line, creating a simple vertical pattern. For example, using a loop, the program can iterate through the characters starting from 'A' to 'E' and print each character. This is often used as a beginner exercise to understand loops and character manipulation in Java.
echo 'print a pattern'
write a program that reads a phrase and prints the number of lowercase latters in it using a function for counting? in C program
With a nested loop this is fairly simple. Example, in Java: for (int i = 1; i
vowels$ = "aeiou" CLS PRINT "PROGRAM: Find if letter is a vowel or not" PRINT INPUT "Type a single alphabet letter: (a-z)/and, then, press Enter key"; aLetter$ PRINT PRINT "Letter "; aLetter$; IF INSTR(vowels$, LCASE$(aLetter$)) THEN PRINT " is a vowel." ELSE PRINT " is NOT a vowel." END
Here's a simple Python program that constructs and displays a pyramid: def print_pyramid(height): for i in range(height): print(' ' * (height - i - 1) + '*' * (2 * i + 1)) print_pyramid(5) This code defines a function print_pyramid that takes the height of the pyramid as an argument and prints a pyramid made of asterisks (*). Adjust the height parameter in the print_pyramid function call to change the size of the pyramid.
Example: start ask the name for each word . print first letter stop
i want to write a simple without using pointer or array c program which will print greatest number when i give 20 number .........How far have you gotten so far?
In QBasic, you can display a new line using the PRINT statement. To create a new line, you can simply use an empty PRINT statement. Here’s a simple example: PRINT "This is the first line." PRINT ' This will create a new line. PRINT "This is the third line." This program will display the first line, then move to a new line, followed by the third line.
The Java pattern program ABCDE typically involves printing the letters A, B, C, D, and E in a specific format. A common implementation is to print each letter on a new line, creating a simple vertical pattern. For example, using a loop, the program can iterate through the characters starting from 'A' to 'E' and print each character. This is often used as a beginner exercise to understand loops and character manipulation in Java.
echo 'print a pattern'
If you want to type a love letter, you can use any word processing program such as Microsoft Word, Google Docs, or even simple text editors like Notepad. These programs allow you to format your letter, add personal touches, and save or print it easily. For a more creative touch, there are also specialized apps designed for writing letters or poetry.
write a program to print A to Z on screen in c?
To print out Christmas card is simple. You need cardstock and a printer attached to your computer. You can create cards of your own with a Word or card program you may have installed on your computer or go to a website such as Ecards.
In GW-BASIC, you can print even numbers from 1 to 100 using a simple loop. Here’s a sample code: FOR i = 1 TO 100 IF i MOD 2 = 0 THEN PRINT i NEXT i This program iterates through numbers 1 to 100 and prints each number if it is even (i.e., divisible by 2).