Share on Google+Share on Google+

sabeena
print hello n hi
1 Answer(s)      4 years and 5 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++;
        }
    }
}









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
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
Advertisements
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
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
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
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
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
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
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");how to display all elements in 2d array usin any one loop
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
print
print  How to print JFrame All Componant?   Please visit the following link: http://www.roseindia.net/java/example/java/swing/Print.shtml
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
Print
into the stream and, as opposed to print() method, gets you to the new line after the text
Hi,
Hi,  Hi,what is the purpose of hash table
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..  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <%@ page contentType="text/html... = "Ilegal ENCTYPE : must be multipart/form-data\n"; err += "ENCTYPE set
hi..
hi..   I want upload the image using jsp. When i browse the file then pass that file to another jsp it was going on perfect. But when i read...-data")) { err = "Ilegal ENCTYPE : must be multipart/form-data\n"; err
hi..
hi..   I want upload the image using jsp. When i browse the file then pass that file to another jsp it was going on perfect. But when i read...-data")) { err = "Ilegal ENCTYPE : must be multipart/form-data\n"; err
hi..
hi..  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <%@ page contentType="text/html... = "Ilegal ENCTYPE : must be multipart/form-data\n"; err += "ENCTYPE set
hi..
hi..  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <%@ page contentType="text/html... = "Ilegal ENCTYPE : must be multipart/form-data\n"; err += "ENCTYPE set
hi..
hi..   I want upload the image using jsp. When i browse the file then pass that file to another jsp it was going on perfect. But when i read...-data")) { err = "Ilegal ENCTYPE : must be multipart/form-data\n"; err
hi..
hi..   I want upload the image using jsp. When i browse the file then pass that file to another jsp it was going on perfect. But when i read...-data")) { err = "Ilegal ENCTYPE : must be multipart/form-data\n"; err
Tutorials   
Java Spring Hibernate Struts Training What does core Java include? java What are some way to learn Java quickly? Is it required to learn Java before learning Java Script? Is it necessary to learn java script before learning PHP? Are HTML5 and Java Script boosts Java career? Is Java object oriented? Fingerprint application with Java Uninstall Oracle Virtual Box JSON to HashMap Free Java online Training I want example of Control Statement in Java ANSI Color Codes with Python Create a Program that Calculates Input What is difference between JDK,JRE and JVM? How to see ubuntu version on server? How to get Page Source in Selenium (WebDriver) using Java? The path to the driver executable must be set by the webdriver.gecko.driver system property parse data from a link in java Java Program Qns using BlueJ How to fix HAX Kernel Module Is Not Installed error? Installing Audacity Looking for code Logic to check track changes & Coments in MSWord, MSWordx, MSExcel, MSExcelx is ON/OFF Installing JDK on Mac SAX Parser exception ERROR 601 (42P00): Syntax error. Encountered Thread java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory How to install Ubuntu 16.04 LTS? HttpServletRequest cannot be resolved to a type in eclipse - Solved Unhandled event loop exception GC overhead limit exceeded Spring Data jpa with apache phoenix Caused by: java.lang.IllegalArgumentException: Not a host:port pair: PBUF o.a.h.h.z.RecoverableZooKeeper - Possibly transient ZooKeeper, quorum= com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager class not found com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager not found How to download and install Java 8 on Windows? How to uninstall JDK 7? How to install gtk-doc-tools package in Ubuntu? How to install Oracle JDK 8 on Ubuntu? ejabberd_ctl.beam not found - Solved How to convert date to UTC format in Java? How to install autoconf, automake and libtool in Ubuntu 15.10? How to convert current date to mm dd yyyy format in Java? How to convert current date to dd mm yyyy format in Java? How to stop window closing in "internalFrameClosing" event. How to find list of all index in Neo4j? neo4j-server.properties file location SASLError using PLAIN: not-authorized how to convert war file into .exe file using java code

Ads

 
Advertisement null

Ads