Problem Statement

The government of India has launched the UID project which aims to give a Unique
Identification number to each Indian. The number is a randomly generated 16 digit number. To
detect errors when typing in this number, we propose to use the last digit as a checksum.
Following are the rules to generate and validate the checksum :-

1. Starting from left to right, sum all odd numbered digits and multiply the sum by 3
2. Sum all even numbered digits and multiply the sum by 7
3. Add the two sums from step 1 and step 2.
4. Divide the number in step 3 by 10 and take the remainder(modulo operation).
5. Subtract the number obtained in step 4 from 10. The result is the check digit.

Lets say that the number is 4583 4323 8143 257(last digit is for check digit)
Sum of odd numbered digits :- 4 + 8 + 4 + 2 + 8 + 4 + 2 + 7= 39 * 3 = 117
Sum of even numbered digits :- 5 + 3 + 3 + 3 + 1 + 3 + 5 = 23 * 7 = 161
Total sum = 117 + 161 = 278
Remainder after dividing 278 by 10 = 2
Therefore, the check digit is 10 - 2 = 8. So the final number is 4583 4323 8143 2572
Similarly, the check digit for 765381206010321 is 7.
Hence, the final number is 7653812060103217.

Write a program to check if the UID number entered is valid or not.

You are free to use a programming language of your choice.

Recommended Answers

All 11 Replies

Plz reply as soon as possible!

thanx in advance!

Remainder after dividing 278 by 10 = 2

The Remainder is not 2, it is 8. (modulo operation)

278/10 = 27.8

Take the number as a String. Actually it should be treated as a String to begin with:
"458343238143257"
Use the String class to convert that into an array of characters and loop the array.
In the loop take the odd indexed characters. Convert each character to a String (String class API), then that Stirng to an int (Integer class API) and then add them. (Classic for-loop for calculating sums)
Do the same for the even indexed characters.
Then follow the instructions: Multiply(2), add(3), divide(4), subtract(5).
Then concatenate the result to the original String.

Use the API of the classes:
java.lang.String
java.lang.Integer

The Remainder is not 2, it is 8. (modulo operation)

278/10 = 27.8

Take the number as a String. Actually it should be treated as a String to begin with:
"458343238143257"
Use the String class to convert that into an array of characters and loop the array.
In the loop take the odd indexed characters. Convert each character to a String (String class API), then that Stirng to an int (Integer class API) and then add them. (Classic for-loop for calculating sums)
Do the same for the even indexed characters.
Then follow the instructions: Multiply(2), add(3), divide(4), subtract(5).
Then concatenate the result to the original String.

Use the API of the classes:
java.lang.String
java.lang.
Integer

hey dude thanx 4 ur reply....

can u plz provide me code 4 d same as i don't know JAVA!!

PLZ....

Perhaps you should write it in a language you know, then.
(You are free to use a programming language of your choice, after all)

Perhaps you should write it in a language you know, then.
(You are free to use a programming language of your choice, after all)

hey dude i m not perfect in ny of prog lang....so i asked!!

Also i m focusing on network oriented career in future.....so don't knw any kinda lang..

i hav 2 mail dis problem 4 project sponsership...

Plz help!!

hey dude i m not perfect in ny of prog lang....so i asked!!

Also i m focusing on network oriented career in future.....so don't knw any kinda lang..

i hav 2 mail dis problem 4 project sponsership...

Plz help!!

Have you attended any programming language lessons? If no then how do you expect to solve this problem.
Are you telling us to give you the solution so you can profit from our work? And then what?...
If this kind of project was asked for the sponsorship, it means that it is required for you to know these things. What will you do after you get the sponsorship? How will you solve future problems?

This problem is very easy. It only requires basic knowledge. Do some studying and read some tutorials.
When was this problem given to you and how much time was given to you to solve this?

hey dude i m not perfect in ny of prog lang....so i asked!!

Also i m focusing on network oriented career in future.....so don't knw any kinda lang..

"Not perfect in any programming language" in the sense of "totally ignorant of all programming languages. Gotcha.

i hav 2 mail dis problem 4 project sponsership...

Plz help!!

So you want us to help you deceive the people you're seeking sponsorship from by giving you code to present as your own, and while we're at it, to facilitate your continuing ignorance? Considering that...
Nope. Sorry, not interested. Good luck, though.

Have you attended any programming language lessons? If no then how do you expect to solve this problem.
Are you telling us to give you the solution so you can profit from our work? And then what?...
If this kind of project was asked for the sponsorship, it means that it is required for you to know these things. What will you do after you get the sponsorship? How will you solve future problems?

This problem is very easy. It only requires basic knowledge. Do some studying and read some tutorials.
When was this problem given to you and how much time was given to you to solve this?

i knw dis man...also ashamed 4 d same..

i nvr took ny of languages seriously.....

i hav 2 mail till 2mrw...

nys thanx 4 all ur concerns...

"Not perfect in any programming language" in the sense of "totally ignorant of all programming languages. Gotcha.

So you want us to help you deceive the people you're seeking sponsorship from by giving you code to present as your own, and while we're at it, to facilitate your continuing ignorance? Considering that...
Nope. Sorry, not interested. Good luck, though.

dude actually i m not intrested in software develoment field....m focusing on n/w oriented career..

I m in final yr engg nw.....project work is compeltion part!!!

evry1 has diff choices....

nys will focus on ur rply 2...

thanx....

dude actually i m not intrested in software develoment field....m focusing on n/w oriented career..

I m in final yr engg nw.....project work is compeltion part!!!

evry1 has diff choices....

nys will focus on ur rply 2...

thanx....

First of all If you have read the forum rules you would know we don't give homework and it also against the rules the way you talk:

i knw dis man...also ashamed 4 d same..
i nvr took ny of languages seriously.....
i hav 2 mail till 2mrw...
nys thanx 4 all ur concerns...

Use proper english! One of your previous post doesn't make any sense!

And if you are not interested in software development field then this sponsorship is not for you because it requires some programming skills .

And if you have to mail this by tomorrow, how long ago was this assignment given to you?

First of all If you have read the forum rules you would know we don't give homework and it also against the rules the way you talk:

i knw dis man...also ashamed 4 d same..
i nvr took ny of languages seriously.....
i hav 2 mail till 2mrw...
nys thanx 4 all ur concerns...

Use proper english! One of your previous post doesn't make any sense!

And if you are not interested in software development field then this sponsorship is not for you because it requires some programming skills .

And if you have to mail this by tomorrow, how long ago was this assignment given to you?

was given today morning itself!

my mind got screwed fully.....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.