Answered step by step
Verified Expert Solution
Question
1 Approved Answer
For the unit 3 assignment, you must develop a program that reads the file I cream.dat. This file is supplied in the Files for Unit
For the unit 3 assignment, you must develop a program that reads the file I cream.dat. This file is supplied in the Files for Unit 3 Assignment directory in Unit 3. You must use TextIO methods to read the file. As you read the file, count the number of ice cream cones that were sold. (This is the same as the number of lines that you read from the file.) Also count the number of Strawberry comes that were sold.
At the end of the program, print out the total number of cones, the number of Strawberry cones, and the percentage of cones that were Strawberry.
Note: To do this program, you have to know when to stop reading the file. TextIO has a function named TextIO.eof to check whether the entire file has been read. The value of this function is true if the entire file has been read. The value is false if there is more data in the file. You want to continue reading from the file as long as TextIO.eof() is false.
Note: suppose that flavor is a variable of type String and you want to test whether its value is Strawberry. To do this, test whether flavor.equals(Strawberry). (Do not use == to test for equality of strings.)
Each line of the file icecream.dat is an ice cream flavor such as Vanilla or Strawberry. A line represents the sale of one ice cream cone of the given flavor.
You must complete your program, test, bug, and execute it. You must submit your java code file. The output of your program must be captured by either copying the content in the output window and pasting it into a text document that you submit along with your java code file, or by capturing the image of the screen which contains the output of your java program.
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