Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  squarecubes.java
Language: JAVA
Code:
import javax.swing.*;
public class squarecubes
{

    
    public static void main(String[] args) 
    {
        int option = JOptionPane.YES_NO_OPTION;
        while(option == JOptionPane.YES_OPTION)
        {
          String squareCube1 = JOptionPane.showInputDialog(null,
                "Please enter an Integer: ", "Welcome to the "
                + "Squares and Cubes Table!", JOptionPane.PLAIN_MESSAGE);
          int squareCube2 = Integer.parseInt(squareCube1);
          int i = (squareCube2);
          int j =(squareCube2);
          int squared = (i*i);
          int cubed = (i*i*i);
          StringBuilder sb = new StringBuilder();
            for( i = 0; i < squareCube2; i++) 
            {
              i = squared;
              sb.append(squareCube2).append(i);
                for(j = 0; j < squareCube2; j++)
                {
                 j = cubed;
                 sb.append(j);
                }
                
            }
         
          JOptionPane.showMessageDialog(null, "NUMBER    SQUARED    CUBED "
                  + "\n======    " + "=======    =====\n" +
                  sb);
            
          
          option = JOptionPane.showConfirmDialog(null, "Do you want to "
                    + "continue?");
        }



    }

}
Comments: