Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Download the following code template files for use as starter code: Diary.java Download Diary.java, Stats.java Download Stats.java, fileIn.txt Download fileIn.txt As you progress through the
Download the following code template files for use as starter code: Diary.java Download Diary.java, Stats.java Download Stats.java, fileIn.txt Download fileIn.txt
As you progress through the lab, look over the relevant starter code file and make sure you know what material has been provided for you.
Section
Summary
Today we will write some programs involving text file input and output. We will be importing some new libraries that contain methods necessary for making file IO work.
Part
In a class called Stats template is provided given a text file of doubles see this labs Canvas page for a sample file write a program that determines the average, the maximum, the minimum and how many numbers are in the following buckets: less than between inclusive and exclusive and greater than or equal to
Your program should print the following message to another file called fileOuttxt:
Statistics for the numbers in fileIn.txt:
average:
max:
min:
There are negative numbers, numbers between inclusive and exclusive and numbers that are greater than or equal to
Optional Challenge work on it after completing the rest of the lab!
Write a program that generates a text file that can be used as input for the problem described above. Use your knowledge of file output, loops and the random method from the Math library. How random and in what range the numbers should be it totally up to you!
Part
In a class called Diary template is provided write a program that prompts users to enter the date as three integers separated by spaces ie mm dd yyyy then it prompts them enter as many lines of prose they wish for their todos list or diary entry Your program should store their entries at the end of a file called diaryLogtxt and old data should NOT be erased. Each entry should be formatted as follows example for a diary entry entered on :
old stuff.
Date:
Dear diary, today we had a midterm. I think it went ok
Part
Write a program Advice.java that gives and takes advice on program writing. The program starts by writing a piece of advice to the screen and asking the user to type in a different piece of advice. The program then ends.
The next person to run the program receives the advice given by the person who last ran the program.
The advice is kept in a text file advice.txt and the content of the file changes after each run of the program. Furthermore, you should have another text file called adviceLog.txt which starts off blank but with each run of the program it logs the advice that was given without deleting the previous advices You should allow the user to type in advice of any length so that it can be any number of lines long. The user is told to end their advice by pressing the Return key two times. Your program can then test to see that it has reached the end of the input by checking to see when it reads an empty string
Input file: advice.txt
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started