A22.0002 Samuel Marateck
ASSIGNMENT 1. MW class (section 02) Assigned date: MON FEB 4. Due MON FEB 11 11:59 pm
TH class (section 04) Assigned date: THURS JAN 31. Due THURS FEB 7 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. (See page 45 in the text, for
example Sring s = JOptionPane.showInputDialog("Type your input");)
Then use, for instance,
int value = Integer.parseInt(num1)
to convert each number to an int (see page 46). 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
and secondOne (here, 36 + 12, or 48) and assign it to a third variable, let's
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 value. Then use
int number = Integer.parseInt(value)
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 the appropriate grader.