Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that opens a file of integers numbers.txt and produces an output file that contains a table with each integer from the input

Write a program that opens a file of integers numbers.txt and produces an output file that contains a table with each integer from the input file and an indication of the properties of the number. The three properties will be 1) does it contain repeating (adjacent) digits? 2) is it even? 3) is it prime.

For example, if the input file, numbers.txt contained:344 171 88

90 51 221 11 111 

The resulting output file numberSummary.txt would contain:

 Repeat Number Digits Even Prime 
 344 + + - 171 - - - 88 + + - 90 - + - 51 - - - 221 + - - 11 + - + 111 + - - 

You must write three methods to test for the number properties:

isPrime(n) - takes an integer value and returns true if the number is prime, false otherwise isEven(n) - takes an integer value and returns true if the number is even, false otherwise isRepeatedDigits(n) - takes an integer value and returns true if the number contains the same digit in adjacent locations in the number, false otherwise

Your main( ) method will use the required methods to produce the well labelled table. A + in the table indicates that thenumber possesses that property, a - indicates it does not.

Your table must be formatted as shown, no use of spaces or tabs is permitted. Your methods should be well-documented using @param and @return tags in the comments. There are an unknown number of integers in the input file, however, you may assume the file contains only integers > 1.

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

Master The Art Of Data Storytelling With Visualizations

Authors: Alexander N Donovan

1st Edition

B0CNMD9QRD, 979-8867864248

More Books

Students also viewed these Databases questions

Question

Why do organizations need to prioritize projects?

Answered: 1 week ago