Question: Consider the class Pen. It has a color (String) and a length (double) and a price (double) Write a method countPens that receives an input
Consider the class Pen. It has a color (String) and a length (double) and a price (double) Write a method countPens that receives an input file name, and does the following: public int countPens(String inputFileName) 1. opens the input file name for reading 2. reads until the end of the input file the information of a pen object 3. Creates an object of type Pen 4. counts and returns the number of pen objects read from the file Sample input file: Red 10.0 20.0 Blue 12.0 50.0 Green 9.0 30.0 Black 12.0 10.0 The methos should return 4
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
