Using a text editor, create a file that contains a list of at least 15 six-digit account numbers. Read in each account number and display whether it is valid. An account number is valid only if the last digit is equal to the remainder when the sum of the first five digits is divided by 10. For example, the number 223355 is valid because the sum of the first five digits is 15, the remainder when 15 is divided by 10 is 5, and the last digit is 5. Write only valid account numbers to an output file, each on its own line. *Note that the contents of the file AcctNumsIn.txt will change when the test is run to test the program against different input.   AcctNumsIn.txt 345619 789400 871208 901156 984334 723422 172257 100000 273699 237485 761200 555500 936716 763542 999995   ValidateCheckDigits.java import java.nio.file.*; import java.io.*; import java.nio.channels.FileChannel; import java.nio.ByteBuffer; import static java.nio.file.StandardOpenOption.*; public class ValidateCheckDigits { public static void main(String[] args) { Path fileIn = Paths.get("/root/sandbox/AcctNumsIn.txt"); Path fileOut = Paths.get("/root/sandbox/AcctNumsOut.txt"); // put code here } }

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter13: File Input And Output
Section: Chapter Questions
Problem 6PE
icon
Related questions
Question

Using a text editor, create a file that contains a list of at least 15 six-digit account numbers. Read in each account number and display whether it is valid. An account number is valid only if the last digit is equal to the remainder when the sum of the first five digits is divided by 10. For example, the number 223355 is valid because the sum of the first five digits is 15, the remainder when 15 is divided by 10 is 5, and the last digit is 5. Write only valid account numbers to an output file, each on its own line.
*Note that the contents of the file AcctNumsIn.txt will change when the test is run to test the program against different input.

 

AcctNumsIn.txt
345619
789400
871208
901156
984334
723422
172257
100000
273699
237485
761200
555500
936716
763542
999995

 

ValidateCheckDigits.java
import java.nio.file.*;
import java.io.*;
import java.nio.channels.FileChannel;
import java.nio.ByteBuffer;
import static java.nio.file.StandardOpenOption.*;
public class ValidateCheckDigits {
public static void main(String[] args) {
Path fileIn = Paths.get("/root/sandbox/AcctNumsIn.txt");
Path fileOut = Paths.get("/root/sandbox/AcctNumsOut.txt");

// put code here
}
}

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
File Input and Output Operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning