Question
You must develop a program that reads the file icecream.dat (it is supplied at the end of this posting) . You must use TextIO methods
You must develop a program that reads the file icecream.dat (it is supplied at the end of this posting) .
You must use TextIO methods to read the file.
As you read the file, count the total 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 total number of "Strawberry" cones 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 from 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, debug, 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. In windows you can capture a screen shot with the Ctrl Alt and Print Screen key sequence. This image can then be pasted into a Word, WordPad, or OpenOffice document which can be submitted with your assignment. For students using the program service online, make sure that you create both the TextIO.java and the icecream.dat files as java project files. I found it was easier to rename icecream.dat to icecream.txt for some reason. For students using Netbeans, use the same set of rules that were defined in Unit 2 to setup your project and include the TextIO.java file. Also make sure that you copy the icecream.dat file into your project directory so that it can be found by your java program.
The icecream.dat file contains this:
Chocolate Mint Vanilla Strawberry Chocolate Vanilla Fudge Ripple Strawberry Chocolate Chocolate Vanilla Vanilla Peanut Butter Vanilla Chocolate Strawberry Strawberry Peanut Butter Vanilla Chocolate Chocolate Mint Vanilla Butter Pecan Rocky Road Vanilla Vanilla Vanilla Chocolate Butter Pecan Peanut Butter Strawberry Fudge Ripple Vanilla Butter Pecan Vanilla Vanilla Chocolate Orange Sherbet Mint Orange Sherbet Butter Pecan Chocolate Vanilla Orange Sherbet Fudge Ripple Butter Pecan Chocolate Chocolate Vanilla Vanilla Vanilla Strawberry Fudge Ripple Peanut Butter Mint Strawberry Vanilla Strawberry Rocky Road Vanilla Strawberry Chocolate Orange Sherbet Vanilla Rocky Road Chocolate Peanut Butter Chocolate Vanilla Chocolate Chocolate Chocolate Butter Pecan Peanut Butter Strawberry Chocolate Chocolate Orange Sherbet Fudge Ripple Strawberry Rocky Road Butter Pecan Orange Sherbet Strawberry Strawberry Fudge Ripple Rocky Road Chocolate Fudge Ripple Peanut Butter Butter Pecan Chocolate Strawberry Butter Pecan Peanut Butter Vanilla Vanilla Vanilla Vanilla Butter Pecan Vanilla Mint Mint Orange Sherbet Vanilla Chocolate Strawberry Peanut Butter Peanut Butter Rocky Road Vanilla Butter Pecan Strawberry Vanilla Strawberry Mint Fudge Ripple Rum Raisin Chocolate Strawberry Orange Sherbet Peanut Butter Vanilla Fudge Ripple Vanilla Strawberry Strawberry Strawberry Vanilla Vanilla Fudge Ripple Fudge Ripple Mint Strawberry Vanilla Vanilla Chocolate Mint Chocolate Vanilla Strawberry Orange Sherbet Vanilla Mint Vanilla Fudge Ripple Orange Sherbet Vanilla Vanilla Mint Chocolate Mint Butter Pecan Vanilla Chocolate Fudge Ripple Chocolate Strawberry Vanilla Chocolate Vanilla Peanut Butter Chocolate Strawberry Orange Sherbet Strawberry Strawberry Rocky Road Vanilla Vanilla Vanilla Vanilla Mint Vanilla Butter Pecan Chocolate Peanut Butter Chocolate Fudge Ripple Vanilla Vanilla Vanilla Orange Sherbet Rocky Road Butter Pecan Vanilla Peanut Butter Fudge Ripple Fudge Ripple Strawberry Chocolate Chocolate Rocky Road Chocolate Fudge Ripple Orange Sherbet Chocolate Strawberry Vanilla Strawberry Strawberry Vanilla Orange Sherbet Vanilla Butter Pecan Vanilla Vanilla Rocky Road Strawberry Vanilla Orange Sherbet Peanut Butter Chocolate Orange Sherbet Vanilla Vanilla Chocolate Chocolate Strawberry Mint Peanut Butter Rocky Road Vanilla Vanilla Mint Chocolate Vanilla Strawberry Butter Pecan Vanilla Vanilla Orange Sherbet Vanilla Fudge Ripple Mint Strawberry Orange Sherbet Vanilla Peanut Butter Chocolate Vanilla Butter Pecan Butter Pecan Chocolate Vanilla Chocolate Chocolate Peanut Butter Vanilla Rocky Road Peanut Butter Vanilla Rocky Road Peanut Butter Strawberry Peanut Butter Vanilla Vanilla Mint Rocky Road Orange Sherbet Vanilla Vanilla Fudge Ripple Mint Vanilla Vanilla Chocolate Mint Chocolate Strawberry Mint Chocolate Butter Pecan Vanilla Chocolate Mint Fudge Ripple Vanilla Vanilla Chocolate Orange Sherbet Butter Pecan Orange Sherbet Chocolate Vanilla Rocky Road Peanut Butter Vanilla Chocolate Vanilla Mint Rocky Road Chocolate Orange Sherbet Vanilla Chocolate Fudge Ripple Strawberry Butter Pecan Vanilla Vanilla Mint Fudge Ripple Vanilla Vanilla Fudge Ripple Fudge Ripple Vanilla Rocky Road Peanut Butter Vanilla Vanilla Mint Vanilla Rocky Road Fudge Ripple Chocolate Chocolate Orange Sherbet Rocky Road Vanilla Mint Strawberry Butter Pecan Vanilla Vanilla Vanilla Rocky Road Vanilla Chocolate Vanilla Strawberry Peanut Butter Vanilla Chocolate Chocolate Mint Strawberry Rocky Road Chocolate Vanilla Strawberry Butter Pecan Vanilla Chocolate Chocolate Strawberry Mint Chocolate Rocky Road Vanilla Strawberry Vanilla Chocolate Vanilla Vanilla Vanilla Rocky Road Vanilla Strawberry Chocolate Chocolate Vanilla Mint Fudge Ripple Vanilla Chocolate Strawberry Strawberry Orange Sherbet Chocolate Strawberry
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