Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program called NumberFun.java that will determine if a positive, whole number is even , prime , a palindrome , or emirp . The

Write a program called NumberFun.java that will determine if a positive, whole number is even, prime, a palindrome, or emirp. The input to the program is a series of numbers, one per line, read from a text file. The program should prompt the user for the input file name.

Each determination is to be written as a separate method that takes as a parameter a positive integer and returns a boolean. The following guidelines can be used in your code:

2 is the only even number that is prime. An odd integer is prime if it is not divisible by any odd integer less than or equal to the square root of the number.

A palindrome reads forward and backward in the same way. For example, the numbers, 5, 131, 2662, and 34543 are palindromes. (When determining if a number is a palindrome, do not convert the number to a string.)

An emirp is a prime number whose reversal is also a prime. For example, 11, 13, 79, and 359 are emirps.

The output lists each number in the file and displays which of the four properties hold true for that number. If none of them hold true, the number is displayed alone. For example, given the input file the output would be:

114 114 - even

4621 4621 - prime

11 11 prime, palindrome, emirp

97 97 prime, emirp

2 2 even, prime, palindrome, emirp

45 45

Add a helper method called printHeading() to your application. The heading of the method should be private static void printHeading() . In the code block of the method, write Java statements that output to the console the following:

* Your name

* The course number and section

* The Java program name and the project number

Include a Java statement at the beginning of your main method that calls the helper method, printHeading().

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

Databases A Beginners Guide

Authors: Andy Oppel

1st Edition

007160846X, 978-0071608466

More Books

Students also viewed these Databases questions