Question
Asked by:
nicholsbradley
nicholsbradley
Rating : No Rating
Questions Asked: 21
Tutorials Posted: 0
 

$10.00 Help Please

Q:
Develop an application that reads product id, product name and product price entered from the user at the keyboard, and writes this information to a text file. Call the output text file products.txt.

The resulting output products.txt file should be of the format:

1001 Rake 20.00
1002 Hose 15.00
1003 Lawnmower 200.00

Product id should be the first field, a one word product description should be the second field, and the product price in dollars and cents (no $) should be the third field. White spaces (no commas) should be used as the delimiter between each field and a platform independent line separator should be used at the end of each product record. Your file may be used as input to a future application which is why the format is important.

The application should repeatedly prompt for this product information until terminated by the user. Do not use Ctrl-Z to terminate as NetBeans does not recognize this for terminating input. In fact, Ctrl-Z is an editing command in NetBeans. After each pass of user entering product information, prompt the user with a choice to continue entering product information or not. Be sure your prompt clearly tells the user what to enter depending on their choice. Using their entered response, determine whether or not you should prompt for another product’s information or terminate the application.

 


   
   
   
   
 
Available Tutorials to this Question
Posted by:
 

$10.00 A complete java application which deals with all of the given conditions

  • This tutorial hasn't been purchased yet.
  • Posted on Jul 05, 2009 at 4:16:24PM
A:
Preview: ... nd th ...

The full tutorial is about 5 words long plus attachments.

Attachments:
Inventory1.zip (1K)
Posted by:
modulo51
modulo51
Rating (110): A-
Questions Asked: 1
Tutorials Posted: 353, earned $2,117.64
 

$10.00 Java Part1, keyboard input w/ Scanner, write to text file using PrintWriter

  • This tutorial was purchased 3 times and rated D by students like you.
  • Posted on Jul 05, 2009 at 5:21:39PM
A:
Preview: ... me, price));<br> }<br> }<br> }<br> // need to close file to get it written properly:<br> closeFile();<br> }<br> // stall the program so that user can compare input with file:<br> System.out.print("\\nPress return to quit program: ");<br> kb.nextLine();<br><br> }<br><br> private static boolean getData() {<br> // added to perform error checking<br><br> String line;<br> String[] part;<br> System.out.print(" id name price: ");<br> // get a comple line<br> line = kb.nextLine();<br> // split line into substrings<br> part = line.split(" "); // spaces is the delimiter<br><br> // there must be exactly 3 pieces of product data on a line:<br> if (part.length != 3) {<br> System.out.println(<br> "Drror: input line must have exactly 3 fields " + ...

The full tutorial is about 1650 words long plus attachments.

Attachments:
Part1.java (4K) (Preview)
Part1ScreenShot.JPG (49K) (Preview)
Part1console.txt (0K) (Preview)
Posted by:
tayunyang
tayunyang
Rating (5): A-
Questions Asked: 0
Tutorials Posted: 60, earned $93.92
 

$10.00 Java write file

  • This tutorial hasn't been purchased yet.
  • Posted on Jul 06, 2009 at 4:38:14PM
A:
Preview: ... Product name Product price, or enter q to quit");<br> isr = new InputStreamReader(System.in);<br> br = new BufferedReader(isr);<br><br> try<br> {<br> fout = new FileOutputStream ("products.txt");<br><br> try<br> {<br> s = br.readLine();<br><br> while (!s.equals("q"))<br> ...

The full tutorial is about 121 words long plus attachments.

Attachments:
JavaWriteFile.zip (12K)
   
Join Now or Log In
Get Tutoring
Get Paid
Academic Honesty