PROGRAM STATEMENT: IDE: Eclipse You are asked to create a small Java program to validate an account number entered on the screen and show a specific calculation based on it. Step 1: Before you start,...

1 answer below »


PROGRAM STATEMENT:



IDE: Eclipse


You are asked to create a small Java program to validate an account number entered on the screen and show a specific calculation based on it.




Step 1:
Before you start, clickHEREto downloadvalidNumbers.txt.It contains a text file with a list of the 200 account numbers that will be considered valid by our program. Place the file in the root of your Workspace folder in Eclipse. You will be using it for this assignment.




Step 2:You will create a single class for this program. You will call the classAccounts.




Step 3:The class must contain:



  • An int array called
    validNumbers
    to store all numberssortedfrom the txt file.

  • A method called
    validator
    that accepts an account number as its argument and returns a Boolean. The method should determine if the number is valid by comparing it to the numbers stored on the
    validNumbers

    array

    .
    If it is valid, the method must return true, if not, must return false.

  • A method calledcalculator
    that adds each digit of a valid account number and returns the calculated value. For example, if the valid number is 98765, then the method will add each of the number's digits (9+8+7+6+5) and return 35.

    1. To do this, store the valid number in a String, then use a loop to traverse the String and extract each character using the String method
      charAt(index)
      and add its value to the result variable.

    2. Please note that you will need to use parse methods and wrapper classes as shown in the lectures to accomplish this part of the assignment.



  • Finally, in themainmethod, your program must ask the user to enter an account number and display if it is valid. If it is not, ask the user to either enter another account number to check or exit. If the account number is valid, display its calculated value from thecalculator
    method and ask if process needs to be repeated to check another number or not (exit).


Test your program at least 3 times with correct and incorrect account numbers.



  • Remember to:

    • Add all necessary comments to your code, including the header comment.



Answered Same DayNov 29, 2021

Answer To: PROGRAM STATEMENT: IDE: Eclipse You are asked to create a small Java program to validate an account...

Sayed Shad Ahmad answered on Dec 01 2021
160 Votes
//Importing class for file reading
import java.io.FileReader;
import java.io.BufferedReader;
//Im
porting class for handling Exceptions
import java.io.IOException;
//Importing Arrays class for sorting Array
import java.util.Arrays;
//Importing Scanner class for user input
import java.util.Scanner;
//Class Accounts
public class Accounts
{
    //Creating an array of 200 integers to store valid account numbers
    private static int validNumbers[] = new int[200];
    
    //Method to validate account number
    public static boolean validator(int accNo)
    {
        //Looping for each element in valid numbers array
        for(int i=0; i        {
            //Checking whether account number matches the i th valid number in array
            if(accNo == validNumbers[i])
                //Returning true
                return true;
        }
            
        //Returning false when none of the valid numbers in array matches the...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here