# 3 - Towson

```Assignment 2 (Due 03/11/2010)
COSC 237-101
Name: Ryan Stevens
ID:0283589
Email : rsteve1@students.towson.edu
Complete the following problems and submit your answers via email. All the program code must
be placed a word document (preferred) and submitted via Blackboard. Please put output of each
program in the word document.
Problem 2.1: Bank account balance
make the program complete.
Hint: The complete source code is in pages 250-251.
Problem 2.2: Reversing Digit
Write a method, reverseDigit,that takes a positive integer as a parameter and returns the number
with its digits reversed. For example, the value of reverseDigit(12345) is 54321. Also write a
program to test it.
Hint: there are two ways to solve the problem: (1) You can use “/” and “%” operation to get the
reversed integer. (2) You use “int aInt = 80; String aString = Integer.toString(aInt);” to convert
the integer value to string; you use for loop to reverse the data in the string (look at example in
page 378); then you use the “String aString = &quot;80&quot;; int aInt = Integer.parseInt(aString);” to return
the integer data.
import java.util.Scanner;
import java.io.*;
public class Reverse {
public static void main (String args[]) {
Scanner in = new Scanner(System.in);
int n=0;
int rev_n = 0;
n = in.nextInt();
while (n &gt; 0) {
rev_n *= 10;
rev_n += n % 10;
n /= 10;
}
System.out.println(&quot;Enter your number reversed is &quot; + rev_n);
}
}
Problem 2.3: Finding Duplications:
Write a program to sign people up for a seminar. Everybody is assigned a ID number in [0, 15].
It will start with a simple routine that asks users to type in their number. Once you have the array
of up to 15 numbers, you will want to check whether some people may have entered their
numbers twice or not. Write a program which shows the one of duplicate numbers?
Hint: To do this, you will want to iterate over the original array using loop. You will examine
each element that you encounter to see if it exists in the new array that you are building (as an
index array). We definitely have an alternative way to do this by using nested loops.
import java.util.Scanner;
import java.io.*;
public class seminar {
public static void main (String args[]) {
Scanner in = new Scanner(System.in);
int[] x = {1, 6, 3, 1, 2, 4, 5, 1, 3, 10};
int n=0;
int y=0;