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
irina [24]
3 years ago
12

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. Note that the contents of the file AcctNumsIn.txt will change when the test is run to test the program against different input. Grading Write your Java code in the area on the right. Use the Run button to compile and run the code. Clicking the Run Checks button will run pre-configured tests against your code to calculate a grade. Once you are happy with your results, click the Submit button to record your score. AcctNumsIn.txt ValidateCheckDigits.java

Computers and Technology
1 answer:
Zanzabum3 years ago
4 0

Answer:

See explaination

Explanation:

/File: ValidateCheckDigits.java

import java.io.BufferedWriter;

import java.io.File;

import java.io.FileWriter;

import java.io.IOException;

import java.util.Scanner;

public class ValidateCheckDigits {

public static void main(String[] args) {

String fileName = "numbers.txt"; //input file name

String validFileName = "valid_numbers.txt"; // file name of the output file

//Open the input file for reading and output file for writing

try(Scanner fileScanner = new Scanner( new File(fileName));

BufferedWriter fileWriter = new BufferedWriter( new FileWriter(validFileName))) {

//Until we have lines to be read in the input file

while(fileScanner.hasNextLine()) {

//Read each line

String line = fileScanner.nextLine().trim();

//calculate the sum of first 5 digits

int sum = 0;

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

sum += Integer.parseInt( line.charAt(i) + "");

}

//Get the last digit

int lastDigit = Integer.parseInt(line.charAt(5)+"");

//Check if the remainder of the sum when divided by 10 is equal to last digit

if(sum%10 == lastDigit) {

//write the number in each line

fileWriter.write(line);

fileWriter.newLine();

System.out.println("Writing valid number to file: " + line);

}

}

System.out.println("Verifying valid numbers completed.");

} catch(IOException ex ) {

System.err.println("Error: Unable to read or write to the file. Check if the input file exists in the same directory.");

}

}

}

Check attachment for output and screenshot

You might be interested in
Please answer this now I need please.
choli [55]

Answer:

You can change the color of text in your Word document. Select the text that you want to change. On the Home tab, in the Font group, choose the arrow next to Font Color, and then select a color.

You can display a graphics window and draw colorful shapes in it if you use the Show operation of the GraphicsWindow object. You can also specify properties of the graphics window, such as its title, height, width, and background color.

Explanation: Sorry I couldn't do the third question but hope it helps.

7 0
3 years ago
What phrase indicates someone has knowledge and understanding of computer,internet,mobile devices and related technologies?
navik [9.2K]

Digital literacy is the term for having knowledge of computers, internet, mobile devices and related technologies.

7 0
3 years ago
When the code that follows is executed, a message is displayed if the value the user entersvar userEntry = (prompt("Enter cost:"
Reika [66]

Answer:

The answer is "Option b".

Explanation:

In the given-code variable "userEntry" is defined that prompt the user to input value and in the next step, the conditional statement is used, which checks the input value is not a number and greater than 500 with use of OR operator. if the condition is true it uses the alert box to print the message, that's why in this question except "choice b" all were wrong.

4 0
3 years ago
PLEASE HELP I FAILED TWICE AND HAVE ONLY ONE MORE TRY BEFORE MY GRADE ARE SET I AM CRYINGGGGG PLEASEEE IM BEGGINGGGGG
anyanavicka [17]

1. C

2. B

3. C

4. A

5. A

6. B

7. C

8. D

9. C

10. B

11. D

12. D

13. D

14. A

15. A

16. B

17. A

18. B

19. D

20. B


Some of the ones towards the start may not be right but I gave it a go :)





8 0
3 years ago
Imagine that you were hired to create the label for a new brand of soup. The client wants to emphasize that the soup has homemad
lidiya [134]

Answer:

Explanation:

For tools, I would simply use Adobe Photoshop to create the label/poster for the brand of soup. In order to make the poster or representation of the soup look homemade, I would place a picture of a kid drinking the soup at a kitchen table with a picture of the mom in the background kitchen. Then I would create a light yellowish tint in the image and steam coming from the soup bowl. This would help the brand represent a form of memory to a delicious homemade meal by a parent.

4 0
3 years ago
Other questions:
  • Your friend, who is a little computer phobic, is going to create his first web page, and he asks you to recommend some software
    13·1 answer
  • âwhat two log files are used by older versions of unix and newer version of linux to store log information
    10·2 answers
  • Using the media as equipment for living. Explain how you would use some form of media to serve a purpose in your life—and what t
    6·2 answers
  • This diagram shows a number of computing devices connected to the Internet with each line representing a direct connection.
    11·1 answer
  • Applications require you to provide the following basic elements: social security number, experience, and favorite memories. Tru
    11·1 answer
  • Which of these would NOT be a valid Internet Control Message Protocol (ICMP) error message:
    6·1 answer
  • Which of the following contributes to your active digital footprint
    12·2 answers
  • 1. Why is photographing lightning a difficult process?
    11·2 answers
  • What is the purpose of a format painter in Word?
    15·2 answers
  • FoRWarD MaRcH AND hERe We Go MEMbers of the agEncy BaKuGO AHHHHHHHHH-
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!