1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Afina-wow [57]
3 years ago
7

Using a text editor, create a file that contains a list of at least 15 six-digit account numbers. Read in each account number an

d 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. Save the application as ValidateCheckDigits.java.
Computers and Technology
1 answer:
grigory [225]3 years ago
3 0

Answer:

Explanation:

The following code is written in Java. It reads every input and checks to see if it is valid. If it is it writes it to the output file.

import java.io.File;

import java.io.FileNotFoundException;

import java.io.FileWriter;

import java.io.IOException;

import java.util.Scanner;

class Brainly {

           public static void main(String[] args) {

               try {

                   File myObj = new File("C:/Users/Gabriel2/AppData/Roaming/JetBrains/IdeaIC2020.2/scratches/input.txt");

                   Scanner myReader = new Scanner(myObj);

                   FileWriter myWriter = new FileWriter("C:/Users/Gabriel2/AppData/Roaming/JetBrains/IdeaIC2020.2/scratches/output.txt");

                   while (myReader.hasNextLine()) {

                       String data = myReader.nextLine();

                       int sum = 0;

                       for (int x = 0; x < 5; x++ ) {

                           sum += data.charAt(x);

                       }

                       int remainder = (sum % 10);

                       System.out.println(remainder);

                       System.out.println(data.charAt(5));

                       if (remainder == Integer.parseInt(String.valueOf(data.charAt(5)))) {

                           System.out.println("entered");

                           try {

                               myWriter.write(data + "\n");

                               System.out.println("Successfully wrote to the file.");

                           } catch (IOException e) {

                               System.out.println("An error occurred.");

                               e.printStackTrace();

                           }

                       }

                       sum = 0;

                   }

                   myWriter.close();

                   myReader.close();

               } catch (FileNotFoundException e) {

                   System.out.println("An error occurred.");

                   e.printStackTrace();

               } catch (IOException e) {

                   e.printStackTrace();

               }

           }

       }

You might be interested in
What is one way to measure technological progress?
OLga [1]
You can measure it by the amount of automatisation. The bigger technological process the easier it is to automate systems.
4 0
3 years ago
What happens if you have Param 1 in your ad, but there is no corresponding value at the keyword level?
nika2105 [10]
Without it, you at will no severe
4 0
3 years ago
Read 2 more answers
6 + 7 = 7 + 6 is an example of which property of addition?
Sauron [17]

Answer:

commutative

Explanation:

The commutative property states that the numbers on which we operate can be moved or swapped from their position without making any difference to the answer.

8 0
3 years ago
Read 2 more answers
What technology provides secure access to websites
wlad13 [49]

The technology is HTTPS or Hypertext Transfer Protocol Secure

6 0
3 years ago
Read 2 more answers
In which job role will you be creating e-papers, newsletters and preiodicals
gogolik [260]

Answer:

The correct answer is: newspaper editor.

Explanation:

Newspaper editors are responsible for creating and updating newspaper material, as well as other outlets such as magazines and, thanks to technology, online papers and newsletters. Such experts must have outstanding grammar and be informative as they are the last knowledge filter before they are sent to the public.

8 0
3 years ago
Other questions:
  • Which windows command always navigates the command-line interface back to the root directory?
    8·1 answer
  • You are the manager and an employee shows up for his shift dressed inappropriately for work. What should you do?
    14·2 answers
  • What is the exact number of bits in a memory that contains (a) 128k bits?
    9·1 answer
  • What is an example of a transition effectl
    7·1 answer
  • Which line in the following program will cause a compiler error? #include using namespace std; int main() { int number =5; if (n
    10·1 answer
  • Which are advantages of using a server operating system?
    12·1 answer
  • What is the difference between = and == in terms of java..?
    6·2 answers
  • Which of the following describe audio-editing software? Choose all that apply.
    5·2 answers
  • the ghost adventures team uses a variety of tools and technology in investigations. which one is described as an adjustable freq
    9·1 answer
  • An IT security threat is anything that might cause serious harm to a computer system.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!