Coding a Program Containing if-then and switch
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.
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.