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
Which of the following is NOT true about a flow chart?
SCORPION-xisa [38]
I think the answer is A
4 0
3 years ago
Kevin would like to ensure that his software runs on a platform that is able to expand and contract as needs change. Which one o
Reil [10]

A terminology which best describe Kevin's goal in terms of expansion and contraction as needs change is: A. Scalability.

<h3>What is scalability?</h3>

Scalability can be defined as a measure of the ability of a system to change (expansion or contraction) in performance and cost as a result of changes in demands of application and system processing, especially in a network architecture.

In this context, we can logically deduce that a terminology which best describe Kevin's goal in terms of expansion and contraction as needs change is scalability.

Read more on scalability here: brainly.com/question/14301721

#SPJ1

Complete Question:

Kevin would like to ensure that his software runs on a platform that is able to expand and contract as needs change.  Which one of the following terms best describes his goal? A. Scalability B. Elasticity C. Cost effectiveness D. Agility

8 0
1 year ago
Universal Containers wants line items to be organized into pre-defined groups on the output document. The name of these pre-defi
devlian [24]

Answer:

Set the Group field on the Line Items type of Template Content record.

Set the New Quote Group field on each Product record with the associated group name.

Explanation:

The two array that can be implemented are:

  • Set the Group field on the Line Items type of Template Content record.
  • Set the New Quote Group field on each Product record with the associated group name.
5 0
3 years ago
How do i install windows 7 on virtual machine?​
liberstina [14]

Choose Start→All Programs→Windows Virtual PC and then select Virtual Machines. Double click the new machine. Your new virtual machine will open onto your desktop. Once it's open, you can install any operating system you want.

3 0
3 years ago
How can a robot differentiate between positive or negative product reviews?
Levart [38]

Answer:

Some of the sites have the rating system for example 3 stars, or the bot has a feature that can capture keywords that include a list of possible indicator that it is a negative review. For example if a user review includes a word "bad" or "horrible" the bot will flag that as a negative review.

Please give brainliest.

3 0
2 years ago
Other questions:
  • What does the Autosum feature on excel do?
    15·1 answer
  • What does xhtml stand for?
    5·2 answers
  • Ruby is creating a presentation. She wants each slide displayed at intervals of five seconds. Which feature in the presentation
    6·2 answers
  • Which button, when pressed, allows light from the subject to fall on the sensor?
    8·1 answer
  • Pinterest, a visual bookmarking Website, logs more than 14 terabytes of new data each day, which means its storage needs are con
    10·1 answer
  • Refer to the exhibit, a technician applies the configuration in the exhibit to an unconfigured router. To verify the configurati
    13·1 answer
  • What is the difference between a Is your Milling machine and grinding machine
    6·1 answer
  • The goal expressed in this definition states that data visualization is about ______ . 1. Interpreting 2. Perceiving 3. Facilita
    6·1 answer
  • How was WiFi discovered?
    8·1 answer
  • There are many best practices for digital recordings. Select the three best practices from the list below. select the best micro
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!