Description
PRG420 Week 1 Individual Assignment Coding a Simple “Hello, world!” Java Program
Individual: Coding a Simple “Hello, world!” Java™ Program
Includes Working Java Build and Program File and Explanation of Code
Resource: Week One Coding Assignment 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.
/**********************************************************************
* Program: PRG420Week1_CodingAssignment
* Purpose: Week 1 Individual Assignment #2
* Programmer: YOUR FULL NAME GOES HERE
* Class: PRG/420 PRG420 PRG 420
* Creation Date: TODAY’S DATE GOES HERE
*********************************************************************
*
**********************************************************************
* Program Summary: This program asks the user for a one-word name
* and then displays a constructed greeting
* that looks like this:
*
* Hello, NAME!
**********************************************************************/
package prg420week1_codingassignment;
/**
*
* @author NETBEANS PLACES YOUR INITIALS HERE
*/
import java.util.Scanner;
public class PRG420Week1_CodingAssignment {
public static void main(String[] args) {
// Create a usable instance of an input device
LINE 1. INSTANTIATE AN INSTANCE OF SCANNER AND ASSIGN IT TO A VARIABLE OF TYPE SCANNER.
// Prompt user for input
LINE 2. USE THE PRINT() METHOD TO PROMPT THE USER FOR HIS OR HER FIRST NAME.
// Capture first word and assign it to A VARIABLE
LINE 3. USE THE NEXT() METHOD OF YOUR SCANNER INSTANCE TO ASSIGN A VALUE TO A STRING VARIABLE.
// Construct the greeting
LINE 4. USE THE PRINTLN() METHOD TO CONSTRUCT A CORRECTLY PUNCTUATED GREETING.
}
}
Reviews
There are no reviews yet.