Steve
Java Numeric Pyramids
4 Answer(s)      7 years ago
Posted in : Java Beginners

Ads

View Answers

October 29, 2009 at 3:39 PM


Hi Friend,

2)
class Program {
public static void main(String[] args) {
int i,j,p,n,m;
m=n=4;
for(int k=1;k<=5;k++){
System.out.print(k);
}
for(int k=4;k>=1;k--){
System.out.print(k);
}
System.out.print("\n");
for(i=1;i<=n;i++) {
for(j=1;j<=m;j++)
System.out.print(j);
for(p=j-2;p>=1;p--)
System.out.print(p);
m--;
System.out.print("\n");

}
}
}
Thanks


October 30, 2009 at 10:41 AM


Hi Friend,

1)
class Program{
public static void main(String []args){
for(int i=9;i>=1;i--){
System.out.print("0");
System.out.println();
for(int j=i;j<=9;j++){
System.out.print(j);
}
}
System.out.print("0");
}
}

Thanks


November 1, 2009 at 4:48 AM


Hello friend thanks for your help, but i made a mistake my second proble it should be:

123454321
_1234321
__12321
___121
____1

but there's no _ before each rows. Hope you could help on this one too. Thanks ^_^


November 4, 2009 at 12:22 PM


Program for Pyramid1:
___________________________________________________________________________
public class Pyramid {
public static void main(String[] args) {
int k;
for(int i=1;i<=10;i++){
k=(10-(i-1));
for(int j=1;j<=i;j++){
System.out.print(""+(k%10));
++k;
}
System.out.println();
}
}
}
-------------------------------------------------------------------------------------
Program For ur modified view of Pyramid2
_______________________________________________________________________
public class Pyramid {
public static void main(String[] args) {
int k;
for(int i=1;i<=10;i++){
k=(10-(i-1));
for(int j=1;j<=i;j++){
System.out.print(""+(k%10));
++k;
}
System.out.println();
}
}
}









Related Tutorials/Questions & Answers:
Java Numeric Pyramids - Java Beginners
Java Numeric Pyramids  Hi! I'm a beginner in Java can somebody help with these two pyramids, I just can't find the right code. Here's the first one. 0 90 890 7890 67890 56789 4567890 34567890 234567890 1234567890
Java numeric promotion
Java numeric promotion  What is numeric promotion
Advertisements
java numeric promotion
java numeric promotion  What is the numeric promotion
Numeric Data Types
Numeric Data Types  Compare numeric data types of java with corresponding data types in C
What is numeric promotion?
What is numeric promotion?   Hi, What is numeric promotion? Thanks,   Hi, The numeric promotion in java used to convert the smaller number type to larger numeric types. In numerical promotion in java program we
Underscores in Numeric Literals
Underscores in Numeric Literals In this section, you will learn about how you can use underscore in Numeric Literals in Java SE 7. In Java SE 7,  You can place any number of underscore( _ ) between digits of numeric literals
Random alpha numeric string of fixed size
In this section, you will learn to generate fixed size alpha numeric string using core Java code
Allow to Enter only numeric data.
Allow to Enter only numeric data.  hi....... I want to ask... that the user should allow to enter only numeric data. I mean to say that if user... that enter only numeric data. So how this can be done? what will be the code
The easy slider plug-in implementing with numeric boxes
The easy slider plug-in implementing with numeric boxes In this tutorial... with numeric boxes.In this example, easySlider plug in used to develop automatic... using easySlider function of jQuery. The numeric boxes highlighted according
how to get a numeric value from a message - JSP-Servlet
how to get a numeric value from a message  dear sir, I have to get a numeric value from a following message matter i.e Dear [1], Your cl is [2] ,el is [3],bonus is[4] Regards HR. This message
Date Class with multiple numeric parameter constructor
.style1 { font-size: medium; } Date class with multiple numeric... Date class object and pass multiple numeric parameters as  the year, month... of the midnight to the related date. This is the example of multiple numeric
Get IP Address in Java
Get IP Address in Java In this example we will describe How to get ip address in java. An IP address is a numeric unique recognition number which is assigned to the devices participating in the network for communication
B - Java Glossary
B - Java Glossary       Java bigdecimal When working with financial, business applications, the programmer should know about the BigDecimal class and numeric formatting
Java File Binary
Java File Binary In this section, you will learn how to write numeric data into the binary file. Description of code: Numeric data converts compactly and faster in a binary format than the text. In the given example, at first, we have
Convert String into long in java
Convert String into long in java In this section you will learn about conversion of numeric type String data into long in java. Converting string to long is similar to converting string to int in java, if you convert string to integer
Java Convert Number to Words
Java Convert Number to Words In this section, you will learn how to convert a numeric value into its equivalent words. The words of the numbers(1-100...; } public void pass(int number) { int word, q; if (number < 10) { show(st1
Java program
Java program  Write a program which performs to raise a number to a power and returns the value. Provide a behavior to the program so as to accept any type of numeric values and returns the results
java program
java program  . Write a program which performs to raise a number to a power and returns the value. Provide a behavior to the program so as to accept any type of numeric values and returns the results
java code
java code  Write a program which performs to raise a number to a power and returns the value. Provide a behavior to the program so as to accept any type of numeric values and returns the results
Convert String To Double
; In this section, we are going to convert a numeric type string value...: This program simply takes a numeric type string at the console with the "Enter numeric type string value:" message and it converts into a double
Convert String To Float
;java StringToFloat Enter the numeric type string value: 50...;    In this section, you will learn to convert a numeric... a numeric type string at the console. The valueOf() method takes a string type
JAVA with HTML
JAVA with HTML  Hello I want an JAVA example that would convert any UNICODE character OR STRING into its Equivalent HTML Numeric[ASCII] values... Like for character ? it's equivalent value is آ like all the other
Java & OOPs
, because not all values in Java are Objects. For example, the basic numeric types...Java & OOPs  Is JAVA a fully Object Oriented Language? or A what degree Java supports Fully OOPs concept?   Java is not a fully object
MX AnimateProperty in Flex4
MX AnimateProperty Effect in Flex4: The AnimateProperty Effect is used to animate a numeric property of a component. The tag of Animateproperty is <mx:Animateproperty>. In this example we use the scaleX property for animate
ZipCodeValidator in Flex4
ZipCodeValidator in Flex4: The ZipCodeValidator class validates the correct length of the numeric value. It checks the length for a five-digit ZIP code, a five-digit+four-digit United States ZIP code. The tag of ZipCodeValidator
Convert String To Long
;  In this section, we are going to convert numeric type string..., define a class named "StringToLong" for java component. Program takes... this program: Output this program.  C:\corejava>java
java - Java Beginners
java  Hi sir .. Write a program in java for Password Generator that should ask from user in the format as given below. Please reply with output...:- Numeric/Alphabetic/Alphanumeric Password Length:- User specifies
Java Project Questions - Java Beginners
Java Project Questions  Hello sir ,I want Course Form in JAVA SWING that includes following contents- 1)Course Id -Numeric 2)Course NAME-TEXT 3)Course Duration-NUMBERS 4)Course Fees-NUMBERS I want to to add,Update,Delete
Usage of Hash Code - Java Interview Questions
Usage of Hash Code  Dear sir, What is Hashcode in Java and What is its usage? Thanks and Regards M.KehtraBalan  Hi Friend, A hashCode is a way of computing a small (32-bit) numeric key from a long
Convert Object to Int
; In this section, we are going to learn to convert a numeric string type...; Code Description: The following program converts numeric string type object...() method of an Integer class takes a numeric string object and returns
Desperately need Java program ASAP - Java Beginners
Desperately need Java program ASAP  I need the source code for a java application that asks the user to enter a 10 character telephone number... with any alphabetic characters that appeared in the original translated to the numeric

Ads

Advertisement