Starting from:

$30

CS520 Module 1 Assignment

CS520 Module 1 Assignment
General Rules for Homework Assignments
 You are strongly encouraged to add comments throughout the program. Doing
so will help your facilitator to understand your programming logic and grade
you more accurately.
 You must work on your assignments individually. You are not allowed to copy
the answers from the others. However, you are encouraged to discuss
approaches to the homework assignment with your section mates and the
facilitator in your section via the discussion board.
 Each assignment has a strict deadline. However, you are still allowed to submit
your assignment within 2 days after the deadline with a penalty. 15% of the
credit will be deducted unless you made previous arrangements with your
facilitator and professor. Assignments submitted 2 days after the deadline
would not be graded.
 When the term lastName is referenced in an assignment, please replace it with
your last name.
You are strongly encouraged to add comments into your program.
Part1 (50 Points)
 Our bank ATM stores the money in the following denominations -- hundreds, fifties,
twenties, tens, fives, twos, and ones. The bank has the following policy. When a
customer withdraws money, the ATM dispenses the amount using the maximum bills
from the highest to the lowest denominations. For example, if the customer requests
an amount of 293, the ATM dispenses 2 hundreds, 1 fifties, 2 twenties, 1 twos, and 1
ones. Program the ATM using the following guidelines.
1.Create a new Java Project in Eclipse named HW1_lastName and complete the
following requirements:
a.Create a package named cs520.hw1
b.Create a class named Banking under the above package with the main
method.
c. The code in the main method should do the following:
i. Prompt the user for a string input value for the amount in dollars
and store it in a variable named input.
ii. Convert the string to an integer and store it in the variable
named amount. You can assume that the user enters a valid
integer number.
iii. Print the converted integer value to the console.
iv. Declare the integer variables named hundreds, fifties, twenties,
tens, fives, twos, and ones.
v. Declare another integer variable named remainingAmount.
vi. Compute the hundreds and the remainingAmount. Print the
information to the console.
vii. Compute the fifties and the remainingAmount. Print the
information to the console.
viii. Compute the twenties and the remainingAmount. Print the
information to the console.
ix. Compute the tens and the remainingAmount. Print the
information to the console.
x. Compute the fives and the remainingAmount. Print the
information to the console.
xi. Compute the twos and the remainingAmount. Print the
information to the console.
xii. Compute the ones. Print the information to the console.
xiii. Using a message dialog, show the summary of the above
values to the user. See the sample input and output below.
Sample Input:
Sample Console Output:
Sample Dialog Output:

Part2 (50 Points)
Three integer numbers (x, y, z) are known as a Pythagorean Triple if the three
numbers satisfy the following criterion:
x
2 + y
2 = z
2
The first few triples are as shown below.
The program should generate all such numbers where x and y are in the range 1 to
100 using the following guidelines:
2.Create a class named Triples with the main method using the same package as
in Part 1.
a.Use a loop to generate the values for x in the range 1 to 100.
b.Now, use a nested loop to generate the values for y. Your loop should
not generate duplicates – for e.g., (3, 4, 5) and (4, 3, 5) are the
same.
c. Calculate the sum of the squares of the values x and y.
d.Using the Math.sqrt method, calculate the square root of the above
sum. The Math.sqrt method returns a double type. (For e..g,
Math.sqrt(13) would return 3.6055…)
e.Cast the above double value to an integer, say z. Now, check if the
square of this integer is the same as the value from step (c)
f. If the above test is true, the pair (x, y, z) is a Pythagorean triple. Print
the values to the console.
Submission:
Create an archive of your Eclipse project using the following steps. Select the
HW1_lastName project in the Eclipse IDE’s Package Explorer or the Navigator
window.
Click File->Export. Select the General->Archive File option. Click Next.
Specify the “To archive file:” entry as say, C:\Temp\HW1_lastName.zip.
The zip file will be created and stored in the C:\Temp folder.
Submit this zip file as an attachment in the Assignment Section. 

More products