1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Setler79 [48]
4 years ago
10

In a class named InputTextToOutputFile.java use the following prompt to get the fileName of the output file from the user: "What

is the name of your output file?" Once the output file is opened, write everything the user types until the input contains "STOP!" Note: Include the line containing "STOP!" as the last thing written to the file. This work must be completed in your textbook ZYBooks -- CMP-326: Programming Methods II No other forms of submission will be accepted.
Computers and Technology
1 answer:
grin007 [14]4 years ago
5 0

Answer:

Detailed program code is written at explaination

Explanation:

Program:

import java.io.File;

import java.io.FileWriter;

import java.io.IOException;

import java.util.Scanner;

public class InputTextToOutputFile

{

public static void main(String[] args) throws IOException

{

Scanner in=new Scanner(System.in);//Scanner object to get user input

System.out.println("What is the name of your output file? ");

String fileName = in.nextLine();//get output file name

File file = new File(fileName);//File object with fileName as input

//Create the file by method file.createNewFile()

if (file.createNewFile())

{

System.out.println("File is created!");

} else {

System.out.println("File already exists.");

}

//FileWriter object with user file name given as input

FileWriter writer = new FileWriter(file);

System.out.println("Enter text to write to a file : ");

String line;//variable to store line content

do {

line=in.nextLine();//get line content from user

writer.write(line+"\n"); //write content to file by adding new line(\n) character

}while(!line.equals("STOP!"));//repeat a loop until user enters "STOP!" line

writer.close();//close the file object

}

You might be interested in
Difference between rainbow six siege starter edition and regular
Svetradugi [14.3K]
Regular means all operators charms etc cost normal price, but the Starter edition increases the price for all of those things but it is cheaper then the reg version
8 0
4 years ago
Please help
guapka [62]

From: Tom Pearson, Manager, District Five

Regarding: New Incoming Manager, Geraldine Hines

Dear Comstock Staff: Beginning March 15, 2018, you will have a new District Five Regional Manager. After 35 years of continuous service, I am leaving all of you to pursue an exciting future.

It has been my pleasure to train my successor, Geraldine Hines, this past year. Geraldine has demonstrated that she shares the company vision to be the employer of choice here in the Valley of the Sun. I am confident that she will lead all of you into the stratosphere as we merge our call centers and expand our donor site availability.

Please give Geraldine the same level of excellence you have given to me, to our staff and to our donors.

Sincerely.

Tom Pearson, Outgoing Manager, District Five

3 0
3 years ago
Imagine that you've properly connected your multimeter into an operating circuit, and the meter's function/range switch is set t
Free_Kalibri [48]
If the meter is set to  read DC voltage in the 20 volt range and it displays a 1 then it should mean 1 volt assuming that the maximum reading would be 20 volts at that setting. But if it is only around 1 volt is might be more accurate to set it at say 2V range to get say 1.6 actual volts.
8 0
3 years ago
Read 2 more answers
Does the game best fiends use data?
Margaret [11]
<span>The game Best Fiends does not need wifi when playing therefore it will not consume your data. This app is about little animals of Minutia lived in peace and concordance, until the night the meteor crushed into Mount Boom! An interesting power changed the vile Slugs who lived there into a group of greenery-eating goons – and now, the Slugs caught the Best Fiends' families!</span>
6 0
3 years ago
Duolcgnitupmoc unscramble the word​
ahrayia [7]

Answer:

The word is computing cloud, since the topic is from computers and technology, and the whole word is backwards.

6 0
3 years ago
Read 2 more answers
Other questions:
  • Local variables:
    7·1 answer
  • Which of the following terms refers to the horizontal line of continuous cells in a table?
    15·2 answers
  • Ben sends a few emails over the weekend to his relatives. Where should Ben place his laptop so that he can avoid slouching while
    11·1 answer
  • In ancient times what did kings and tribals chiefs use to communicate
    10·1 answer
  • Using a windows computer, to make a window wider, you would move the pointer until it changes to the horizontal resize shape and
    6·1 answer
  • When working with arrays, most programming languages perform ________, which means they do not allow programs to use invalid sub
    5·1 answer
  • What feature adjusts the top and bottom margins so that the text is centered vertically on the printed page?
    14·1 answer
  • What is the binary for O?​
    5·2 answers
  • Pls help me computer science discoveries
    5·1 answer
  • Write the code to call a CSS file named "exam.css".
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!