Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.niallkader.samplecode;
- import java.io.File;
- import java.util.Date;
- import java.util.Scanner;
- import javafx.scene.chart.PieChart.Data;
- public class FileApp {
- public static void main(String[] args) {
- /*
- Create an app that collects data for how much time you spend doing homework.
- When the app is run, it should prompt the user "How many hours did spend on homework?"
- Save the user input as a float.
- The program should then save the user input, along with the date of the entry, in a file.
- The file name is already set up for you in the FILE_PATH constant below.
- Use the Date class to record the time of the entry (you can use the toString() to convert into the text to save)
- The line saved to the file should look like this:
- Wed Apr 15 22:19:31 CDT 2020,2.4
- Notice how the (date) string is separated from the float by a comma
- Use the FileHelper class to save the data by doing the following:
- 1. Open the contents of the file and store it's contents in a String,
- 2. Append (concatenate) the data that was just entered by the user.
- 3. Save the concatenated string to the file
- After saving the data, sysout "Here is all the data...."
- Then display the contents of the file.
- It should include the latest entry
- */
- final String FILE_PATH = "time-spent-on-homework.txt";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement