Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using Netbeans Java IDE Using Netbeans, Include the TextIO.java file. Also make

ID: 3826613 • Letter: U

Question

Using Netbeans Java IDE

Using Netbeans, 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.

You must develop a program that reads the file icecream.dat. (see below)

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.

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

Explanation / Answer

icecream.dat (Save this file under D Drive.Then the path of the file pointing to it is D:\icecream.dat )

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

_____________________

package org.students;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.Scanner;

public class TextIO {

   public static void main(String[] args) {

       //Declaring variables
       int strawCount = 0, totcones = 0;
       Scanner scanner = null;

       try {
//Opening the file
           scanner = new Scanner(new FileInputStream("D:\icecream.dat"));

           //This while loop will read the file until the end of the file
           while (scanner.hasNextLine()) {
              
               //if the cone is strawberry then count it
               if (scanner.next().equals("Strawberry")) {
                   strawCount++;
               }
              
               //Counting total no of cones
               totcones++;
           }
       } catch (FileNotFoundException e) {

           e.printStackTrace();
       } finally {
           scanner.close();
       }
      
       //displaying total no of cones
       System.out.println("Total No Of Cones :" + totcones);
      
       //displaying total no of strawberry cones
       System.out.println("The number of Strawberry cones :" + strawCount);
      
       //calculating the percentage
       double percent = ((double) strawCount / totcones)*100;
      
       //Displaying the percentage
       System.out.printf("The percentage of cones that were Strawberry :%.2f",percent);
   }

}

___________________

output:

Total No Of Cones :495
The number of Strawberry cones :48
The percentage of cones that were Strawberry :9.70

_____________Thank You