print hello n hi

Ads

 
 

Share on Google+Share on Google+

sabeena
print hello n hi
1 Answer(s)      4 years and 11 months ago
Posted in : Java Beginners

how to write a java program that prints "hello" 5 times, "hi" 1 time n again "hello" 4 times..?? do reply..

Ads
View Answers

November 10, 2012 at 1:00 PM


class HelloTest {
    public static void main(String[] args) {
        int i = 5, j = 1;
        while (j <= 5) {
            for (int x = 1; x <= i; x++) {
                System.out.println(x + " - Hello");
            }
            for (int y = 1; y <= j; y++) {
                System.out.println(y + " - Hi");
            }
            i--;
            j++;
        }
    }
}

Ads









Related Tutorials/Questions & Answers:
print hello n hi
print hello n hi  how to write a java program that prints "hello" 5 times, "hi" 1 time n again "hello" 4 times..?? do reply
print the newline
print the newline  Why doesn?t the following code print the newline properly? <?php $str = ?Hello, there.\nHow are you?\nThanks for visiting.?; print $str; ?>   Hi friends, Inside the single quotes \n (newline
Advertisements
how to print hello world every second till i have pressed enter key
how to print hello world every second till i have pressed enter key  how to print hello world every second till i have pressed enter key
hello
Java Error in Hello World  Java Error in Hello World
hello
Java Hello World  HELLO World program in Java
write a java program to print marklist of n students. input Register number, name and marks of three subjects.
write a java program to print marklist of "n " students. input Register number, name and marks of three subjects.  write a java program to print marklist of "n " students. input Register number, name and marks of three subjects
hi,
hi,  print("code sample");how to display all elements in 2d array usin any one loop
hello
another question..n try to do it... an internet service provider has three..."); } System.out.println ("Total monthly bill \n" + payrate); } } i think there is so many error...please try check it out..   Hello Friend, We have
hello
hello  how to print from a-z, A-Z with exact order using for loop? Thanks for all concern
hello
character is vowel or not.   Hello Friend, Try the following code... it... :)... i've another question..n try to do it... an internet service provider has... monthly bill \n" + payrate); } } i think there is so many error
Hello
Hello  Hello sir i want to store upload doc file in ms access by using servlet. Can i store file in access.one another things access only text size is 255 character but my file is up to 2mb how i can store
Hello ..
Hello ..  Hello, I need a code for .. Want to read csv file (which is having name nd mobile number) from jsp and if i give search by name mobile number should get displayed and if i give mobile number name should get
hi
hi   'print("code sample");`class example(){ public.static.void.main(); system.out.println("this is first pro");}   class example{ public static void main(String[]args){ System.out.println("this is first pro
Write a java program that prints the decimal representation in reverse. (For example n=173,the program should print 371.)c
. (For example n=173,the program should print 371.)c  class rose { int n; int i; rose(int n,int i) { n=173; i=371; } void out { System.out.println("Enter the number"+n); System.out.println("\nReverse the number"+i); } Public
hi
hi  what is the code for printing stars as follows * * * * * * * * * *print("code sample");   Hi Friend, Try... num=4; int p = num; int q = 0; for (int i = 0; i <= num; i++) { for (int j
how to print the content of file in 2d matrix having same dimension as given in file(n*m).
how to print the content of file in 2d matrix having same dimension as given in file(n*m).   here is code: import java.io.File; import... to specify no. of columns every time. it is not the case. but i want to print the file
print
print  How to print JFrame All Componant?   Please visit the following link: http://www.roseindia.net/java/example/java/swing/Print.shtml
how to print the average of each column of 2d n*m array using java
how to print the average of each column of 2d n*m array using java  ...).useDelimiter("\n"); while (scanner.hasNext... in the given file having say n*m matrix.   import java.io.File; import
Hi,
Hi,  Hi,what is the purpose of hash table
Print
into the stream and, as opposed to print() method, gets you to the new line after the text
Hi,
Hi,   labels = new Hashtable<Integer,JLabel>
Hi..
Hi..   what are the keywords available in simple HelloWorld program
Hi..
Hi..  what are access specifier available in java
HI.
HI.  hi,plz send me the code for me using search button bind the data from data base in dropdownlist
Hi..
Hi..  null is a keyword.True/False?   hi friend, In Java true, false and null are not a Java keyword they are literals in Java. For reading in detail go through the following link The null keyword
hi
hi  i want to use dropdown list(combo box) in html...it should contain name of country's i,e fetched from db...country names should come from db to html dropdown list...and when user selects perticular country it should go 2 db n
hi
hi  i want to use dropdown list(combo box) in html...it should contain name of country's i,e fetched from db...country names should come from db to html dropdown list...and when user selects perticular country it should go 2 db n
hi
hi  i want to use dropdown list(combo box) in html...it should contain name of country's i,e fetched from db...country names should come from db to html dropdown list...and when user selects perticular country it should go 2 db n
hi
hi  i want to use dropdown list(combo box) in html...it should contain name of country's i,e fetched from db...country names should come from db to html dropdown list...and when user selects perticular country it should go 2 db n
Hi
Hi  Hi this is really good example to beginners who is learning struts2.0 thanks
Hi
Hi  Hi How to implement I18N concept in struts 1.3? Please reply to me

Ads

 
Advertisement null

Ads