Advertisement
Guest User

Untitled

a guest
Apr 20th, 2020
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. package com.niallkader.samplecode;
  2.  
  3. import java.io.File;
  4. import java.util.Date;
  5. import java.util.Scanner;
  6.  
  7. import javafx.scene.chart.PieChart.Data;
  8.  
  9. public class FileApp {
  10.  
  11. public static void main(String[] args) {
  12.  
  13. /*
  14. Create an app that collects data for how much time you spend doing homework.
  15. When the app is run, it should prompt the user "How many hours did spend on homework?"
  16. Save the user input as a float.
  17. The program should then save the user input, along with the date of the entry, in a file.
  18. The file name is already set up for you in the FILE_PATH constant below.
  19. Use the Date class to record the time of the entry (you can use the toString() to convert into the text to save)
  20. The line saved to the file should look like this:
  21.  
  22. Wed Apr 15 22:19:31 CDT 2020,2.4
  23.  
  24. Notice how the (date) string is separated from the float by a comma
  25.  
  26. Use the FileHelper class to save the data by doing the following:
  27. 1. Open the contents of the file and store it's contents in a String,
  28. 2. Append (concatenate) the data that was just entered by the user.
  29. 3. Save the concatenated string to the file
  30.  
  31. After saving the data, sysout "Here is all the data...."
  32. Then display the contents of the file.
  33. It should include the latest entry
  34. */
  35.  
  36. final String FILE_PATH = "time-spent-on-homework.txt";
  37.  
  38. }
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement