import javax.swing.*; /* Program Title: Intro Lab 1 Bugs: None known Description: This lab demonstrates the arithmetic operations. */ public class Arithmetic { public static void main(String[] args) { int a, b; // a and b are declared to be integer variables String numstr1, numstr2; // numstr1 and numstr2 are declared to be strings /* This is put here to cause trouble later! */ // Get integers as strings of characters numstr1 = JOptionPane.showInputDialog(null,"Enter first integer:"); numstr2 = JOptionPane.showInputDialog(null,"Enter second integer:"); // Convert them to integers a = Integer.parseInt(numstr1); b = Integer.parseInt(numstr2); JOptionPane.showMessageDialog(null,"a = " + a +"\n" // \n means end of line + "b = " + b +"\n" +"a + b = " + (a+b) + "\n" +"a - b = " + (a-b) + "\n" +"a * b = " + (a*b) + "\n" +"a / b = " + (a/b) + "\n" +"a % b = " + (a%b) + "\n"); System.exit(0); } }