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
Write the definition of a function max that has three int parameters and returns the largest.
g100num [7]

Solution:

The definition of a function max that has three int parameters and returns the largest is given bellow:

def max(x,y,z):

if (x>z and x>y):

return (x)

elif (y>x and y>z):

return y

else:

return z

Thus this is required right answer.

4 0
3 years ago
Read 2 more answers
A. True
vlada-n [284]
True <span>when an input file is opened, the read position is initially set to the first item in the file.</span>
8 0
3 years ago
In order for a computer to pass the ________, a human should have a conversation with it and not be able to tell if it was a mac
Katena32 [7]

The test that a computer needs to pass after a human's conversation with it and not be able to tell if it was a machine or a human is; Turing Test

<h3>Test of Computers</h3>

The correct answer to the blank portion of the question is Turing test. This is because Turing Test is a test of a computer's ability to exhibit intelligent behavior that is equivalent to, or indistinguishable from, that of a human's behavior.

Finally, If the evaluator cannot reliably tell the computer from the human, the machine is said to have passed the test.

Read more about Test of Computer at; brainly.com/question/21283135

8 0
2 years ago
What is Dailymotion Cloud on the Dailymotion site?
lana [24]
C, a video solution that is adaptable to the users storage space
4 0
2 years ago
Read 2 more answers
What is the difference between operating systems and application software?
Oliga [24]
The operating system is what allows the user to interact with the computer's hardware. It has basic services such as accepting commands from the user, managing, loading, and executing programs, and managing hardware resources. Some examples of operating systems are Windows, Linux, Mac OSX, and IOS.

Application software are pieces of software that perform specific tasks such as word processors.
5 0
3 years ago
Other questions:
  • If all of Earth's history were squeezed into one 12-hour period, how long ago did Precambrian time end? How long did the Cenozoi
    15·1 answer
  • ou work as network administrator for an organization that has a Windows-based network. You want to use multiple security counter
    10·1 answer
  • You can precede a subquery with the ___ operator to create a conditiion that is true if one or more rows are obstained when the
    10·1 answer
  • Which two fields in an Ethernet frame help synchronize device communica- tions but are not counted toward the frame’s size?
    11·1 answer
  • Assuming that the user enters 45 and 62 as inputs for n1 and n2, respectively, what is the output of the following code snippet?
    15·1 answer
  • what version of the internet do we use as an interactive social system in which users are able to interact with senders
    7·1 answer
  • Before measuring resistance of a component, be sure:
    8·1 answer
  • What are the advantages of customer relationship managment​
    10·1 answer
  • you are investigating the use of website and url content filtering to prevent users from visiting certain websites. which benefi
    15·1 answer
  • which classification of money describes money that can be accessed quickly and easily, and includes coins and paper money as wel
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!