PRG420 Week 4 Individual Assignment Coding a Program Containing an Array

Availability: In stock

Regular Price: $10.00

Special Price: $7.00

OR

PRG420 Week 4 Individual Assignment Coding a Program Containing an Array Coding and Output

Double click on above image to view full picture

Zoom Out
Zoom In

More Views

Quick Overview

PRG420 Week 4 Individual Assignment Coding a Program Containing an Array


Individual: Coding a Program Containing an Array


Includes Working Java Build and Program File and Explanation of Code
Resource:  Week Four 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 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 Assignment 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.


/********************************************************************
* Program:    PRG420Week4_CodingAssignment
* Purpose:       Week 4 Individual Assignment #2
* Programmer:    Iam A. Student
* Class:         PRG/420  PRG420 PRG 420
* Creation Date:   TODAY'S DATE GOES HERE
*********************************************************************
*
*********************************************************************
*  Program Summary: This program demonstrates these basic Java concepts:
*     - Creating an array based on user input
*     - Accessing and displaying elements of the array
*
* The program should declare an array to hold 10 integers.
* The program should then ask the user for an integer.
* The program should populate the array by assigning the user-input integer
* to the first element of the array, the value of the first element + 100 to
* the second element of the array, the value of the second element + 100 to
* the third element of the array, the value of third element + 100 to
* the fourth element of the array, and so on until all 10 elements of the
* array are populated.
*
* Then the program should display the values of each of the array
* elements onscreen. For example, if the user inputs 4, the output
* should look like this:
*
* Enter an integer and hit Return: 4
* Element at index 0: 4
* Element at index 1: 104
* Element at index 2: 204
* Element at index 3: 304
* Element at index 4: 404
* Element at index 5: 504
* Element at index 6: 604
* Element at index 7: 704
* Element at index 8: 804
* Element at index 9: 904
***********************************************************************/
package prg420week4_codingassignment;
import java.util.Scanner;
public class PRG420Week4_CodingAssignment {
 public static void main(String[] args) {
  
  // LINE 1. DECLARE AN ARRAY OF INTEGERS


  // LINE 2. ALLOCATE MEMORY FOR 10 INTEGERS WITHIN THE ARRAY.


  // Create a usable instance of an input device
  Scanner myInputScannerInstance = new Scanner(System.in);
  
  // We will ask a user to type in an integer. Note that in this practice
  // code  WE ARE NOT VERIFYING WHETHER THE USER ACTUALLY
  // TYPES AN INTEGER OR NOT. In a production program, we would
  // need to verify this; for example, by including
  // exception handling code. (As-is, a user can type in XYZ
  // and that will cause an exception.)
  System.out.print("Enter an integer and hit Return: ");
  
  // Convert the user input (which comes in as a string even
  // though we ask the user for an integer) to an integer
  int myFirstArrayElement = Integer.parseInt(myInputScannerInstance.next());
  
  // LINE 3. INITIALIZE THE FIRST ARRAY ELEMENT WITH THE CONVERTED INTEGER myFirstArrayElement
  


  // LINE 4. INITIALIZE THE SECOND THROUGH THE TENTH ELEMENTS BY ADDING 100 TO THE EACH PRECEDING VALUE.
  // EXAMPLE: THE VALUE OF THE SECOND ELEMENT IS THE VALUE OF THE FIRST PLUS 100;
  // THE VALUE OF THE THIRD ELEMENT IS THE VALUE OF THE SECOND PLUS 100; AND SO ON.


  
  // LINE 5. DISPLAY THE VALUES OF EACH ELEMENT OF THE ARRAY IN ASCENDING ORDER BASED ON THE MODEL IN THE TOP-OF-CODE COMMENTS.
  
 } 
}

Regular Price: $10.00

Special Price: $7.00

Details

PRG420 Week 4 Individual Assignment Coding a Program Containing an Array

Individual: Coding a Program Containing an Array

Includes Working Java Build and Program File and Explanation of Code
Resource:  Week Four 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 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 Assignment 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.

/********************************************************************
* Program:    PRG420Week4_CodingAssignment
* Purpose:       Week 4 Individual Assignment #2
* Programmer:    Iam A. Student
* Class:         PRG/420  PRG420 PRG 420
* Creation Date:   TODAY'S DATE GOES HERE
*********************************************************************
*
*********************************************************************
*  Program Summary: This program demonstrates these basic Java concepts:
*     - Creating an array based on user input
*     - Accessing and displaying elements of the array
*
* The program should declare an array to hold 10 integers.
* The program should then ask the user for an integer.
* The program should populate the array by assigning the user-input integer
* to the first element of the array, the value of the first element + 100 to
* the second element of the array, the value of the second element + 100 to
* the third element of the array, the value of third element + 100 to
* the fourth element of the array, and so on until all 10 elements of the
* array are populated.
*
* Then the program should display the values of each of the array
* elements onscreen. For example, if the user inputs 4, the output
* should look like this:
*
* Enter an integer and hit Return: 4
* Element at index 0: 4
* Element at index 1: 104
* Element at index 2: 204
* Element at index 3: 304
* Element at index 4: 404
* Element at index 5: 504
* Element at index 6: 604
* Element at index 7: 704
* Element at index 8: 804
* Element at index 9: 904
***********************************************************************/
package prg420week4_codingassignment;
import java.util.Scanner;
public class PRG420Week4_CodingAssignment {
 public static void main(String[] args) {
  
  // LINE 1. DECLARE AN ARRAY OF INTEGERS

  // LINE 2. ALLOCATE MEMORY FOR 10 INTEGERS WITHIN THE ARRAY.

  // Create a usable instance of an input device
  Scanner myInputScannerInstance = new Scanner(System.in);
  
  // We will ask a user to type in an integer. Note that in this practice
  // code  WE ARE NOT VERIFYING WHETHER THE USER ACTUALLY
  // TYPES AN INTEGER OR NOT. In a production program, we would
  // need to verify this; for example, by including
  // exception handling code. (As-is, a user can type in XYZ
  // and that will cause an exception.)
  System.out.print("Enter an integer and hit Return: ");
  
  // Convert the user input (which comes in as a string even
  // though we ask the user for an integer) to an integer
  int myFirstArrayElement = Integer.parseInt(myInputScannerInstance.next());
  
  // LINE 3. INITIALIZE THE FIRST ARRAY ELEMENT WITH THE CONVERTED INTEGER myFirstArrayElement
  

  // LINE 4. INITIALIZE THE SECOND THROUGH THE TENTH ELEMENTS BY ADDING 100 TO THE EACH PRECEDING VALUE.
  // EXAMPLE: THE VALUE OF THE SECOND ELEMENT IS THE VALUE OF THE FIRST PLUS 100;
  // THE VALUE OF THE THIRD ELEMENT IS THE VALUE OF THE SECOND PLUS 100; AND SO ON.

  
  // LINE 5. DISPLAY THE VALUES OF EACH ELEMENT OF THE ARRAY IN ASCENDING ORDER BASED ON THE MODEL IN THE TOP-OF-CODE COMMENTS.
  
 } 
}

Product Tags

Use spaces to separate tags. Use single quotes (') for phrases.