PRG421 Phoenix Week 2 Console Input and Output Programming Project Resource: “Console/File Input and Output” text file For this assignment, you will buil
PRG421 Phoenix Week 2 Console Input and Output Programming Project Resource:
“Console/File Input and Output” text file
For this assignment, you will build on “starter” code to create a Java™ program that prompts the user for input, accepts user input, and produces both console and file output.
Copy the linked code to a JAVA file.
Add Java® code based on the comments inside the code.
Note: Refer to this week’s Individual “Week Two Analyze Assignment” for model code you can adapt to meet this assignment’s requirements.
Test, debug, and run your code using the NetBeans editor to make sure it meets the program requirements.
/**********************************************************************
* Program: Week 2 Code Assignment
* Purpose: Console/file input and output
* Programmer: YOUR NAME HERE
* Class: PRG/421r13, Java Programming II
* Instructor: YOUR INSTRUCTOR HERE
* Creation Date: TODAY’S DATE
* Comments: Fill in code
*
***********************************************************************/
package demo;
import java.util.Scanner; // scanner is a predefined class for taking inputs from user
public class Startercode
{
public static void main(String[] args)
{
// prompts and accepts user input
Scanner input= new Scanner(System.in);
double data;
System.out.println(“Enter value “);
// accepts file input
String fileName = “input.txt”; // name of the file to open
String line = null; // will reference one line at a time
try {
FileReader fileReader = // FileReader reads text file
new FileReader(fileName); // reads in data from the file
// produces both console and file output
try { // coding block to output data to file
fileStdout = new PrintStream(new FileOutputStream(“data.txt”)); // output file name is data.txt
System.out.println(“==============”); // output to console, numbers 0 through 9
fileStdout.println(“” + i);
// ENTER YOUR CODE HERE. Enter code to end program successfully.