Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Marketing The Ultimate Marketing Tool

Authors: Edward L. Nash

1st Edition

0070460639, 978-0070460638

Students also viewed these Databases questions

Question

How would you describe your typical day at work?

Answered: 1 week ago