evelop a program that reads the file icecream.dat (supplied in the “Files for Unit 3 Assignment) // Use TextIO methods to read the file //
// develop a program that reads the file icecream.dat (supplied in the “Files for Unit 3 Assignment) // Use TextIO methods to read the file // Count the total number of ice cream cones that were sold (number of lines that you read from the file) // Count the total number of "Strawberry" cones that were sold. // Print out the total number of cones, the number of Strawberry cones, and the percentage of cones that were Strawberry. // 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. // If flavor is a variable of type String and you want to test whether its value is "Strawberry", // 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. // 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 as we did in unit 2 // Make sure that you copy the icecream.dat file into your project directory so that it can be found by your java program.
7 years ago
Purchase the answer to view it

- java-code.zip