subject

"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.
here is the code given with the comments of instruction included:
/
* 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.
this is the analyze assignment that we are to reference for model code we can adapt to meet this assignment's requirements.
/
* program: fileout
* purpose: demonstrate the coding to produce output to a file.
* programmer: i am student
* class: prg/421r13, java programming ii
* instructor:
* creation date: 01/03/2018
*
/
package fileout;
import java. io.*;
public class fileout {
public static void main(string[] args) {
inputstream istream;
outputstream ostream=null;
// fileoutputstream creates an outputstream that you can use to write bytes to a file.
int c; // character stream
final int eof = -1; // eof indicator
istream = system. in;
// if the data. txt file already exists, present its contents on the console.
string filename = "data. 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
// always wrap filereader in bufferedreader (to verify)
bufferedreader bufferedreader =
new bufferedreader(filereader);
system. out. println("here are the contents of the current file named " + filename + ": \n");
while((line = bufferedreader. = null) {
system. out. println(line); // verify / display what is read in by the program
}
bufferedreader. close(); // close file
}
catch(filenotfoundexception ex) { // coding to verify file can be opened
system. out. println( // if not open, error message to display
"unable to open file '" +
filename + "'");
}
catch(ioexception ex) { // exception, when there is an error in reading
system. out. println(
"error reading file '"
+ filename + "'");
}
// now, let's construct a new file containing user input.
system. out. println("\ntype characters to write to file. after you finish, press ctrl+shift+del to end.");
file outfile = new file("data. txt"); // create a new file
try { // try block for eof indicator
ostream = new fileoutputstream(outfile);
while ((c = istream. = eof) // look for end of file in istream
ostream. write(c);
} catch (ioexception e) {
system. out. println("error: " + e.;
} finally {
try { // try block for file error ñ file did not close
istream. close(); // close input and output
ostream. close();
} catch (ioexception e) {
system. out. println("file did not close");
}
}
}
}

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 10:50
A911 dispatcher is the sole sender of messages to all police officers. while on patrol, officers communicate with the dispatcher who, in turn, relays messages to other officers. the officers do not communicate directly with one another. this illustrates a network.
Answers: 1
question
Computers and Technology, 22.06.2019 22:10
Asequential circuit contains a register of four flip-flops. initially a binary number n (0000 ≤ n ≤ 1100) is stored in the flip-flops. after a single clock pulse is applied to the circuit, the register should contain n + 0011. in other words, the function of the sequential circuit is to add 3 to the contents of a 4-bit register. design and implement this circuit using j-k flip-flops.
Answers: 1
question
Computers and Technology, 23.06.2019 04:00
Write a method that takes in an array of point2d objects, and then analyzes the dataset to find points that are close together. be sure to review the point2d api. in your method, if the distance between any pair of points is less than 10, display the distance and the (x,y)s of each point. for example, "the distance between (3,5) and (8,9) is 6.40312." the complete api for the point2d adt may be viewed at ~pf/sedgewick-wayne/algs4/documentation/point2d.html (links to an external site.)links to an external site.. try to write your program directly from the api - do not review the adt's source code.
Answers: 1
question
Computers and Technology, 23.06.2019 07:30
What part of the interface displays the external references contained in a selected cell? the status bar the review tab the scroll bar the formula bar
Answers: 1
You know the right answer?
"console/file input and output" text file
for this assignment, you will build on "starter" co...
Questions
question
Mathematics, 18.12.2020 21:00
question
Mathematics, 18.12.2020 21:00
question
Mathematics, 18.12.2020 21:00
question
Computers and Technology, 18.12.2020 21:00
question
Mathematics, 18.12.2020 21:00
Questions on the website: 13722363