A22.0002 Samuel Marateck

ASSIGNMENT 1. Assigned date: Thurs Sept 14, 2006; Due date THU, Sept 21 11:59 pm

>The assignment requires you to write two separate programs and thus consistes of two parts. The first part is to write a program that reads two numbers, let's say num1 and num2, each time using JOptionPane.showInputDialog, Then use, for instance,

int value = Integer.parseInt(num1)

to convert each number to an int. Then add them and print the results.

The second part is to write a program that reads a 4-digit int, for instance, 3612, call it number. The program should separate the first two digits from the last two, and then add them. Thus in our example the program would assign 36 to a variable, let's say firstOne, and then assign 12 to a second variable, let's say secondOne. Finally, it would add the sum of firstOne and secondOne (here, 36 + 12, or 48) and assign it to a third variable, let's say sum.

The output of your program should show the 4-digit integer read, the integer formed from the first two digits, the integer formed from the last two and then their sum. Hint: Use the %(mod) and /(intger division).

Use JOptionPane.showInputDialog to read your data and assign the input to the string number. Then use

int value = Integer.parseInt(number)

to convert number to an int.

This program must be done on the computer and the due-date is one week from the day that its assigned. Please attach the java programs for both programs and send them to your grader.