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
Green Fields Landscaping Company sells evergreen trees which are priced by height. Customers have a choice of purchasing a tree
Tomtit [17]

Answer:

Answered below

Explanation:

//Program is written in Python programming //language.

number_of_trees = int(input ("Enter number of trees purchased: "))

height_of_trees = float(input("Enter height of trees: "))

delivery_status = input("Do you want trees delivered? enter yes or no ")

price_of_two_meters = 20

total_price = number_of_trees * price_of_two_meters

//Invoice

print (number_of_trees)

print(height_of_trees)

print (total_price)

print (delivery_status)

8 0
3 years ago
An organization needs to maintain data files of its employees in the form of tables. They also need to access and update over th
QveST [7]
DBMS (DataBase Management System)
6 0
3 years ago
Read 2 more answers
Tips to identify email scams.
malfutka [58]

Answer:

Explanation:

dont open or sign up to anything that seems to good to be true

7 0
3 years ago
1.Give single word
EastWind [94]

Answer:

A. Versatile

B. Accuracy

C. High speed

D. Animation.

5 0
3 years ago
What is<br>assembly language​
lilavasa [31]

Explanation:

An assembly language is a type of low-level programming language that is intended to communicate directly with a computer's hardware. Unlike machine language, which consists of binary and hexadecimal characters, assembly languages are designed to be readable by humans.

7 0
3 years ago
Read 2 more answers
Other questions:
  • Digital art is created by using
    6·1 answer
  • Which delivery model is an example of a cloud computing environment that provides users with a web based email service ?
    9·2 answers
  • Help?!<br> Does anyone know how to use Adobe SoundBooth?
    14·2 answers
  • "As a ____ database management system, Access is particularly powerful because you can enter data once and then retrieve informa
    6·1 answer
  • Help what is a computer made from (computer class question)!!
    9·1 answer
  • This needs to be written in Java.
    11·1 answer
  • In apersuasive message, opposing ideas should be:
    13·1 answer
  • Calculate the performance of a processor taking into account stalls due to data cache and instruction cache misses. The data cac
    11·1 answer
  • Which term describes the distance from one point on a wave to the same point on the next wave?
    13·2 answers
  • if we try to use tail-recursive rules to implement non-tail-recursive rules, it will normally result in rules that are
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!