/**
* 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?
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
==== '----------------------------------------------- '*** PROGRAM: Main Menu ' LANGUAGE: QBASIC: VERSION: QB64 '----------------------------------------------- '------------------------------------------ '*** Global variable declarations list... '------------------------------------------ userKeyPress$="" '----------------------- '*** Main Program... '----------------------- DO 'this is a menu driven program... GOSUB clearScreen GOSUB printMainMenuTitleHeading GOSUB printMainMenuOptionsList GOSUB printMainMenuInstructionsHeading GOSUB printMainMenuUserInstructions GOSUB awaitUserKeyPress GOSUB checkUserKeyPress LOOP UNTIL UCASE$(userKeyPress$) = "Q" '...UCASE converts lower case to upper END '...END of program/halt program code execution '---------------------- '*** Sub-routines... '---------------------- clearScreen: CLS '...(CL)ear the output (S)creen RETURN printMainMenuTitleHeading: PRINT "MAIN MENU" PRINT "========" RETURN printMainMenuOptionsList: PRINT "Hit key: <1> for Program 1: 12 X Tables Square" PRINT "Hit key: <2> for Program 2: Select a times tables to print out" PRINT PRINT "Hit key: <Q> to Quit!" PRINT RETURN printMainMenuInstructionsHeading: PRINT "USER INSTRUCTIONS" PRINT "==============" RETURN printMainMenuUserInstructions: PRINT "In order to select from the above Main Menu options list..." PRINT PRINT "First, chose the type of program you wish to run..." PRINT "by, carefully, reading it's description." PRINT PRINT "Then, hit a corresponding single number/letter key, either: '1'/'2';" PRINT "or, alternatively, hit key: 'Q' to Quit!" PRINT PRINT "-Thank you!" RETURN awaitUserKeyPress: DO '...keep looping until when user presses any key... userKeyPress$ = INKEY$ '...store any IN-coming KEY press LOOP UNTIL userKeyPress$ <> "" RETURN checkUserKeyPress: IF userKeyPress$ = "1" THEN GOSUB program1 '...GO to named SUB-routine IF userKeyPress$ = "2" THEN GOSUB program2 '...GO to named SUB-routine RETURN program1: GOSUB clearScreen PRINT "PROGRAM 1" '(...program 1/code goes here...) GOSUB awaitUserKeyPress RETURN program2: GOSUB clearScreen PRINT "PROGRAM 2" '(...program 2/code goes here...) GOSUB awaitUserKeyPress RETURN
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?
echo 'print a pattern'
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.
Print Server
print it how you normally would and then staple it together.. simple
write a program that reads a phrase and prints the number of lowercase latters in it using a function for counting? in C program
Use the option File / Print in the program you are using.