Control Structures And User-defined Methods

Program files for each of the following three programs:

Largest
Palindrome
Diamond
At the beginning of ALL your programs put the program name, your name, and a brief description of the program.

Example:
/*********************************************************************
Program Name: Largest
Programmers Name: Steve Hortz
Program Description: This program will display the largest number among 10 numbers, etc…
**********************************************************************/

How to submit your assignment:

The programs MUST have the same names as the assignment title.

Each Java source file (*.java) must include a corresponding class file (*.class) program as evidence of success.

You must use a Zipped Folder to send your Weekly Assignment to the DropBox. Do not send subfolders within your zipped folder. Place ALL of the .java and .class files for the week into the one zipped folder. The Zip folder should be named: YourLastName Week 2, and this Zip folder will contain all the weekly programming assignments.

Put all program source files in a word document with a screen shot of all your program output.

L A B S T E P S
STEP 1: Largest (10 points)

Write a Java application program called Largest.java that inputs a series of 10 single-digit numbers and determines and prints the largest of the numbers. Except main() method, no other user-defined method is required. Your program should use at least the following three variables:

a) counter: A counter to count to 10 (that is, to keep track of how many numbers have been input and to determine when all 10 numbers have been processed);

b) number: The current digit input to the program;

c) largest: The largest number found so far.

STEP 2: Palindrome (15 points)

A palindrome is a sequence of characters that reads the same backward as forward. For example, each of the following five-digit integers is a palindrome: 12321, 55555, 45554 and 11611. Write an application called Palindrome.java that reads in a five-digit integer and determines whether it is a palindrome. If the number is not five digits long, display an error message dialog indicating the problem to the user. When the user dismisses the error dialog, allow the user to enter a new value.

Your program will have the following four methods:

main() method, which controls the execution of the program

retrieveInput() method, which prompts and retrieves the input values

check() method, which determines whether it is a palindrome

display() method, which displays the result.

STEP 3: Diamond (15 points)

Write a program called Diamond.java that uses a method diamondOfAsterisks() that displays a diamond (the row number of a diamond must be odd) of asterisks whose row is specified in an integer parameter row. For example, if row is 7, the method displays the pattern of asterisks at the top of the next page.

*

***

*****

*******

*****

***

*

Leave a Reply

Your email address will not be published. Required fields are marked *