Friday, 6 December 2019

Write a complete Java program for the following questions

Q. Write a complete Java program for the following questions:    
         Write a program that print the following on the screen.
Java
Java Java
Java Java Java
Java Java Java Java
Java Java Java Java Java

Solution:

 
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
   public static void main (String[] args) throws java.lang.Exception
   {
       int i,j;
       for(i=0;i<5;i++)
       {
           for(j=0;j<=i;j++)
               System.out.print("JAVA ");
             
           System.out.println();
       }
   }
}

No comments:

Post a Comment