Question

You are hired by a college to write a Java program

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.util.Scanner;

public class CheckSum
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter student id: ");

String studentId = sc.nextLine();

String[] nums = studentId.split("");
int[] id = new int[nums.length];
for(int i = 0; i < id.length; i++)
{
id[i] = Integer.parseInt(nums[i]);
}

int checkSum = 0;
for (int i = 0; i < id.length - 1; i++)
{
checkSum = ((i+1)*id[i])%10;
}
if (checkSum != id[id.length-1])
{
System.out.println("Enter id: " + studentId + " is invalid");
}
else
{
System.out.println("Enter id: " + studentId + " is valid");
}
}
}

Add a comment
Know the answer?
Add Answer to:
You are hired by a college to write a Java program to use a so-called check...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • java program QUESTION 2: 1. Write a do-while loop that asks the user to select a...

    java program QUESTION 2: 1. Write a do-while loop that asks the user to select a task from the following menu to continue: 1. Option 1 2. Option 2 3. Option 3 4. Option 4 5. Exit Read the selection from the keyboard then write the switch statement: For option 1, display the message "Do the option 1" For option 2, display the message "Do the option 2" For option 3, display the message "Do the option 3" For option...

  • JavaFX Write a program that displays a histogram to show the number occurrences of each number...

    JavaFX Write a program that displays a histogram to show the number occurrences of each number in an input sequence. There should be a text filed to accept users input numbers and button to show the histogram. Enter your student number (9 digit number) to generate your unique histogram. A student with ID 100013456 will give a histogram like the following one (note the text filed and button are not shown in the following histogram, BUT is required for the...

  • x= Suppose you are building a program for teaching kids' math. Write a java program the...

    x= Suppose you are building a program for teaching kids' math. Write a java program the does the following: 1. Ask the user if he/she wants to sign-up a. If yes continue to step 2 b. If no Display the message "Thank you, Have a nice Day 2. Ask the user to enter a username. 3. Ask the user to enter a password with at least 8 characters long 4. Write a method with the following header: public static Boolean...

  • You have been asked to write a program to grade several multiple-choice exams. The exam has...

    You have been asked to write a program to grade several multiple-choice exams. The exam has 20 questions, each answered with a letter in the range of ‘a’ through ‘f’. The answers key is declared in the program as constant of type string. An example of answer key is “abcdefabcdefabcdefab”. Your program should work for any other answer key. The program should first ask users for the number of students to be graded. Then it should have a while loop...

  • Java: The local Driver's License Office has asked you to write a program that grades the...

    Java: The local Driver's License Office has asked you to write a program that grades the written portion of the driver's   license exam. The exam has 20 multiple choice questions.   Here are the correct answers:    1. B  6. A  11.B  16. C    2. D  7. B  12.C  17. C    3. A   8. A  13.D  18. B    4. A  9. C  14.A  19. D    5. C  10. D  15.D  20. A    Your program should store the correct answers in an array. (Store each question's answer in an element of a String array.) The program...

  • Java Program: In this project, you will write a program called GradeCalculator that will calculate the...

    Java Program: In this project, you will write a program called GradeCalculator that will calculate the grading statistics of a desired number of students. Your program should start out by prompting the user to enter the number of students in the classroom and the number of exam scores. Your program then prompts for each student’s name and the scores for each exam. The exam scores should be entered as a sequence of numbers separated by blank space. Your program will...

  • Project 1, Program Design 1. Write a C program replace.c that asks the user to enter...

    Project 1, Program Design 1. Write a C program replace.c that asks the user to enter a three-digit integer and then replace each digit by the sum of that digit plus 6 modulus 10. If the integer entered is less than 100 or greater than 999, output an error message and abort the program. A sample input/output: Enter a three-digit number: 928 Output: 584 2. Write a C program convert.c that displays menus for converting length and calculates the result....

  • Write a JAVASCRIPT program that will help an elementary school student learn multiplication. Use the Random...

    Write a JAVASCRIPT program that will help an elementary school student learn multiplication. Use the Random method to produce two positive one-digit integers. The program should then prompt the user with a question using random numbers, such as How much is 6 times 7? The student then inputs the answer. Next, the program checks the student’s answer. If it is correct, display the message "Very good!" and ask whether the student wants to continue if so then ask another multiplication...

  • USE C++ 2.) Write a program that will prompt the use to enter 10 numbers in...

    USE C++ 2.) Write a program that will prompt the use to enter 10 numbers in an array, then display: the 1st, the 5th and the last number. Example, if the user entered 1 2 3 4 5 6 7 8 9 10, the output shall be: 1st is 1 5th is 5 last is 10

  • Your instructor would like you to write a program in Java which would ask for the clerk to enter ...

    Your instructor would like you to write a program in Java which would ask for the clerk to enter the total amount of the customer’s order. The program will then calculate a seven percent (7%) sales tax. Commission is computed based on the following: order amount id="mce_marker" - $200 commission is 2%, order amount $201 - $400 commission is 3%, order amount $401 - $600 commission is 4%, order amount > $600 commission is 5%, The program will display the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT