Analyzing a Simple Java™ Program
Analyzing a Simple Java™ Program
Analyzing Java™ code–that is, reading and predicting the outcome of Java™ code, given one or more inputs–is an essential skill. The ability to analyze code allows you to learn from example code and tutorials. It also allows you to write and debug your own Java™ code.
For this assignment, you will be analyzing the Java™ code in the linked zip file.
Carefully read through the code line by line, then answer the following questions in a Microsoft® Word document:
1. What syntax signals a Java™ comment? (In other words, what symbol(s) tell the Java™ compiler not to process certain text?)
2. Type the line(s) of code that accept user input.
3. Type the line(s) of code that process user input.
4. Type the line(s) of code that produce output.
5. Type the result this program would produce if a user, when prompted, responded by typing “everyone” and then hit Enter.
6. Type the result this program would produce if a user, when prompted, responded by typing in “Mickey Mouse” and hit Enter.
7. Type the result this program would produce if a user, when prompted, responded by typing “Benjamin Franklin” and hit Enter.
Submit your completed Word document using the Assignment Files tab.
PRG420 Java Programming I
Week 1 Assignment
Coding a Simple “Hello, world!” Java™ Program
Resource: Week One Coding Assigment Zip File (starter code for this assignment that includes placeholders)
For this assignment, you will apply what you learned in analyzing a simple Java™ program by writing your own Java™ program. The Java™ program you write should do the following:
• Display a prompt on the console asking the user to type in his or her first name
• Construct the greeting string “Hello, nameEntered!”
• Display the constructed greeting on the console
Complete this assignment by doing the following:
1. Download and unzip the linked zip file.
2. Add comments to the code by typing your name and the date in the multi-line comment header.
3. Replace the following lines with Java™ code as directed in the file:
• LINE 1
• LINE 2
• LINE 3
• LINE 4
4. Comment each line of code you add to explain what you intend the code to do.
5. Test and modify your Java™ program until it runs without errors and produces the results as described above.
Note: Refer to this week’s analyzing code assignment if you need help.
Submit your Java source (.java) code file using the Assignment Files tab.
PRG420 Java Programming I
Week 2 Assignment
Learning Team: FAQ: Decision Constructs
Answer the following questions as a team:
1. In what circumstances would a programmer use if-then-else instead of if-then?
2. What is the advantage of using the switch statement over a series of if-then-else statements?
3. Why does my code not recognize the “if/else” lines and fall through to the “then” code line?
After your team has finished answering the questions collectively, add them, along with the question text, to your Java FAQ document. Refer to the Week 1 Task, “Learning Team: Formatting a Java™ FAQ”.
The team member responsible for submitting the team’s work will submit the formatted FAQ document containing this week’s questions and answers using the Assignment Files tab.
PRG420 Java Programming I
Week 2 Assignment
Analyzing a Program Containing if-then and switch
Resource: Week Two Analyze Assignment Zip File
The ability to read through Java™ code and predict the results, given
specific inputs, is an extremely useful skill.
For this assignment, you will be analyzing the Java™ code in the linked
zip file, and predicting the results given specific input.
Carefully read through the code line by line, then answer the following
questions in a Microsoft® Word document:
1. What is the output of the program as it is written?
2. What would the output of the program be if you assigned iAmHappy to false, num to 35, and numDayOfWeek to 5?
3. What would the output of the program be if you assigned the iAmHappy to 5, num to 50, and numDayOfWeek to 8?
Submit your completed Word document using the Assignment Files tab.
PRG420 Java Programming I
Week 2 Assignment
Coding a Program Containing if-then and switch
Resources: Week Two Coding Assigment Zip File (starter code for this
assignment that includes placeholders), and Week Two Recommended Activity Zip File (examples of how to code a switch statement, an if-then-else statement, and how to construct a string to display text onscreen).
For this assignment, you will apply what you learned in analyzing Java™ code so far in this course by writing your own Java™ program.
The Java™ program you write should do the following:
• Accept user input that represents the number of sides in a polygon. Note: The code to do this is already written for you.
• If input value is not between 3 and 5, display an informative error message
• If input value is between 3 and 5, use a switch statement to display a message that identifies the correct polygon based on the number of sides matching the input number (e.g., triangle, rectangle, or polygon)
Complete this assignment by doing the following:
1. Download tnd unzip ahe linked Week Two Coding Assigment Zip File.
2. Read the file carefully, especially the explanatory comments of what the existing code does.
3. Add your name and the date in the multi-line comment header.
4. Refer to the following linked Week Two Recommended Activity Zip File to see examples of how to code all of the Java™ statements (i.e., switch, println(), and if-then-else) you will need to write to complete this assignment.
5. Replace the following lines with Java code as directed in the file:
• LINE 1
• LINE 2
6. Comment each line of code you add to explain what you intend the code to do.
7. Test and modify your Java™ program until it runs without errors and produces the results as described above.
Note: Refer to this week’s analyzing code assignment if you need help.
Submit your Java source (.java) code file using the Assignment Files tab.
PRG420 Java Programming I
Week 3 Assignment
Learning Team: FAQ: Loops
Answer the following questions as a team:
1. What is an endless loop, and how can a programmer avoid coding one?
2. In what situation should a programmer choose a while loop over a do-while loop, and why?
3. What is a nested loop?
After your team has finished answering the questions collectively, add them, along with the question text, to your Java FAQ document. Refer to the Week 1 Task, “Learning Team: Formatting a Java™ FAQ”. The team member responsible for submitting the team’s work will submit the formatted FAQ document containing this week’s questions and answers using the Assignment Files tab.
PRG420 Java Programming I
Week 3 Assignment
Analyzing a Program Containing Loops
Resource: Week Three Analyze Assignment Zip File
For this assignment, you will be analyzing the Java™ code in the linked Week Three Analyze Assignment Zip File, and predicting the results.
You will also examine both the code and the output for inconsistencies and clarity. This Java™ code includes examples of for, while, and dowhile loops.
Carefully read through the code line by line, then answer the following questions in a Microsoft® Word document:
1. What is the output of the program as it is written?
2. What improvement(s) could be made to this code to make the output clearer or more accurate, or to make the code easier to maintain?
Note: You do not have to make the improvements in the Java™ program, although you certainly may. For this assignment, simply describe the things you see that would need to be improved to elevate the code and output to a more professional level. For the code, consider variable names and hardcoding. For the output, consider formatting/punctuation, repetition, accuracy of information, and wording.
Submit your completed Word document using the Assignment Files tab.
PRG420 Java Programming I
Week 3 Assignment
Coding a Program Containing Loops
Resource: Week Three Coding Assigment Zip File (starter code for this assignment that includes placeholders)
For this assignment, you will apply what you learned in analyzing for, while, and do-while loops by writing these statements yourself. The Java™ program you write should do the following:
• Display a pyramid of asterisks onscreen (i.e., a nested for loop)
• Display the integers 10 to 1 in decreasing order, one number per line (i.e., a while/do-whlie loop)
• Add 7 until the sum becomes greater than 157, at which point the program should display both the sum and the number of 7s added Complete this assignment by doing the following:
1. Download and unzip the linked Week Three Coding Assigment Zip File.
2. Add comments to the code by typing your name and the date in the multi-line comment header.
3. Replace the following lines with Java™ code as directed in the file:
• LINE 1
• LINE 2
• LINE 3
4. Comment each line of code you add to explain what you intend the code to do and why you chose each type of loop.
5. Test and modify your Java™ program until it runs without errors and produces the results as described above.
Note: Refer to this week’s analyzing code assignment if you need help.
Submit your Java source (.java) code file using the Assignment Files tab.
PRG420 Java Programming I
Week 4 Assignment
Learning Team: FAQ: Arrays
Answer the following questions as a team:
1. What data types can an array contain?
2. How do you delete (remove) a value from an array?
3. How do you “read” (access and display) the values or elements in an array?
4. What happens to an array when the program ends?
After your team has finished answering the questions collectively, add them, along with the question text, to your Java FAQ document. Refer to the Week 1 Task, “Learning Team: Formatting a Java™ FAQ”.
The team member responsible for submitting the team’s work will submit the formatted FAQ document containing this week’s questions and answers using the Assignment Files tab.
PRG420 Java Programming I
Week 4 Assignment
Analyzing a Program Containing Arrays
Both Programs Work and Provide the Same Results but are codes a little differently.
Resource: Week Four Analyze Assignment Zip File
The ability to read through Java™ code and predict the results, given specific inputs, is an extremely useful skill.
For this assignment, you will be analyzing the Java™ code in the linked Week Four Analyze Assignment Text File, and answering questions about the array that appears in the code.
Carefully read through the code line by line, then answer the following questions in a Microsoft® Word document:
1. If an array had not been chosen to hold the data manipulated in this program, how else (i.e., with what other data types) could it have been represented?
2. Which approach, using an array or using the alternative you identified in question #1, is shorter/easier?
3. What is the output of this program?
4. What would be the result of using a println() statement to display the value of arraynum[8]?
5. How many values can arraynum contain, and why?
Submit your completed Word document using the Assignment Files tab.
PRG420 Java Programming I
Week 4 Assignment
Coding a Program Containing an Array
Resource: Week Four Coding Assigment Zip File (starter code for this assignment that includes placeholders)
For this assignment, you will apply what you learned in analyzing a simple Java™ program by writing your own Java™ program that creates and accesses an array of integers. The Java™ program you write should do the following:
• Create an array to hold 10 integers
• Ask the user for an integer. Note: This code has already been written for you.
• Populate the array. Note: The first element should be the integer input by the user. The second through tenth elements should each be the previous element + 100. For example, if the user inputs 10, the first array value should be 10, the second 110, the third 210, and so on.
• Display the contents of the array on the screen in ascending index order.
Complete this assignment by doing the following:
1. Download and unzip the linked Week Four Coding Assigment Zip File.
2. Read each line of the file carefully, including the detailed instructions at the top.
3. Add comments to the code by typing your name and the date in the multi-line comment header.
4. Replace the following lines with Java™ code as directed in the file:
• LINE 1
• LINE 2
• LINE 3
• LINE 4
• LINE 5
5. Comment each line of code you add to explain what you intend the code to do.
6. Test and modify your Java™ program until it runs without errors and produces the results as described above.
Note: Refer to this week’s analyzing code assignment if you need help.
Submit your Java source (.java) code file using the Assignment Files tab.
PRG420 Java Programming I
Week 5 Assignment
Learning Team: FAQ: Exceptions and Strings
Answer the following questions as a team:
1. When would a programmer use String vs. StringBuilder?
2. What are Java™ exceptions, and why should programmers handle them?
3. What is the difference between a Java™ error and a Java™ exception?
4. What is the difference between a checked exception and an unchecked exception?
After your team has finished answering the questions collectively, add them, along with the question text, to your Java FAQ document. Refer to the Week 1 Task, “Learning Team: Formatting a Java™ FAQ”.
The team member responsible for submitting the team’s work will submit the formatted FAQ document containing this week’s questions and answers using the Assignment Files tab.
PRG420 Java Programming I
Week 5 Assignment
Analyzing a Program Containing Exception Handling
Resource: Week Five Analyze Assignment Zip File
For this assignment, you will be analyzing the code in the linked Week Five Analyze Assignment Zip File. This program contains exception handling code. You will be evaluating the code and using what you learned in this week’s readings to predict the results based on the program as written, as well as based on changing the value of a specific variable.
Carefully read through the code line by line, then answer the following questions in a Microsoft® Word document:
1. What are the results of the program as written?
2. What results would the program produce if you changed the value of a from 0 to 3?
Submit your completed Word document using the Assignment Files tab.
PRG420 Java Programming I
Week 5 Assignment
Coding a Program Containing Exception Handling
Resource: Week Five Coding Assigment Zip File (starter code for this assignment that includes placeholders)
For this assignment, you will apply what you learned in analyzing a simple Java™ program by writing your own Java™ program. The Java™ program you write should do the following:
• Organize the code capable of throwing an exception of type ParseException as a try block.
• Include a catch block to handle a ParseException error thown by the try block.
• Include a hard-coded error that results in a ParseException to prove that the code can catch and handle this type of exception.
Complete this assignment by doing the following:
1. Download and unzip the linked Week Five Coding Assigment Zip File.
2. Add comments to the code by typing your name and the date in the multi-line comment header.
3. Replace the following lines with Java™ code as directed in the file:
• LINE 1
• LINE 2
4. Replace the value assigned with one of the variables so that the program throws an exception.
5. Comment each line of code you add to explain what you intend the code to do. Be sure to include a comment for the replacement value you added in Step 4 that causes the program to throw an exception.
6. Test and modify your Java™ program until it runs without errors and produces the results described above.
Note: Refer to this week’s analyzing code assignment if you need help.
Submit your Java application file using the Assignment Files tab.
Collepals.com Plagiarism Free Papers
Are you looking for custom essay writing service or even dissertation writing services? Just request for our write my paper service, and we'll match you with the best essay writer in your subject! With an exceptional team of professional academic experts in a wide range of subjects, we can guarantee you an unrivaled quality of custom-written papers.
Why Hire Collepals.com writers to do your paper?
Quality- We are experienced and have access to ample research materials.
We write plagiarism Free Content
Confidential- We never share or sell your personal information to third parties.
Support-Chat with us today! We are always waiting to answer all your questions.