Input in Java with JOptionPane or Scanner examples of code

Exercise with swing class and JOptionPane class

Exercise with swing class and JOptionPane class package javaapplication1; import javax.swing.*; public class JavaApplication1 { public static void main(String[] args) { int a1,a2; a1=0;a2=0; int i=0; int iterate; String tmp=””; tmp=JOptionPane.showInputDialog(“enter how many iterations you want to do”); iterate=Integer.parseInt(tmp); while (i<=iterate) { System.out.println(a1+ ” “+ a2); i++; a1=a1+2; a2=a2+3; } } } esercise with input with scanner public static void main(String[] args) { // TODO code application logic here int i1 = 0; int i2 = 0; Scanner x = new Scanner(System.in); System.out.println(“Enter an input: “); i1 = x.nextInt(); System.out.println(“Enter another input: “); i2 = x.nextInt(); int sum = i1 + i2; System.out.println(“The sum of the two numbers is: ” + sum); }