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
Viktor has climbed a tall tree to get a good view of the giraffes on the savannah. He is snapping lots of photographs of the gir
igomit [66]

Answer: C. a good vantage point

3 0
3 years ago
To add slides to a presentation, _____.
Effectus [21]
<span>select the New Slide option from the Insert menu</span>
7 0
3 years ago
In 2009 to 2010, how many social network users were reported as being victims of online abuse?
Dafna1 [17]
The answer is B because being victims of online abuse is not important
7 0
3 years ago
Read 2 more answers
how many squares can be formed by connecting four of the dots in this 5x5 array? (make sure to consider all types of squares!)
aliina [53]

25 SQUARES

How this is calculated?

  • The size of the squares doesn't matter, since the number of squares will be the same.
  • We have a row of 5 squares: and on top of this you stack 5 more squares.
  • Doing this for a total of 5 times so that we  have 5 rows with 5 squares each.
  • So we have 5 + 5 + 5 + 5 + 5 = 25 squares.

What is an array?

  • An array is a data structure that holds similar, related data.
  • Before an array can be used, it must be declared. To declare an array a programmer gives it at least two properties:
  1. an identifier
  2. a size - the number of elements it will hold

To know more about arrays, refer:

brainly.com/question/26104158

#SPJ4

4 0
2 years ago
Does scope frequently changes during a project?<br>​
lesya [120]

Answer:

no

Explanation:

6 0
3 years ago
Read 2 more answers
Other questions:
  • Marisol manages the online advertising campaigns for a chain of toy stores with both a physical and an online presence. Which Go
    7·1 answer
  • ICT excel data homework
    10·1 answer
  • The central processing unit (CPU) processes the data in a computer systenpical data processing includes:
    10·1 answer
  • What are the two categories of problems that we can simply convert<br> to parallel code?
    10·1 answer
  • Connect 5 LEDs with any random colors. Iteratively, turn ON 1 to 5 LED(s) that will take 5 iterations in total, and in every ite
    6·1 answer
  • Benefits of computer in bank​
    5·1 answer
  • Teniendo en cuenta la realidad mundial acerca de la pandemia, ¿cómo crees que impacta
    9·1 answer
  • Explain the<br>4 ways<br><br>ways of arranging icons.<br><br>​
    6·1 answer
  • How tp access to all tools in ms word
    10·1 answer
  • What is the output?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!