জাভা প্রোগ্রামিং পর্ব-২৩



Problem : (Business: checking ISBN) An ISBN (International Standard Book Number) consists of 10 digits d1d2d3d4d5d6d7d8d9d10 The last digit d10 is a checksum, which is calculated from the other nine digits using the following formula: 

(d1x1+d2x2+d3x3+d4x4+d5x5+d6x6+d7x7+d8x8+d9x9)%11

If the checksum is 10, the last digit is denoted X according to the ISBN convention. Write a program that prompts the user to enter the first 9 digits and displays the 10- digit ISBN (including leading zeros). Your program should read the input as an integer. For example, if you enter 013601267, the program should display 0136012671.

File name : Isbn.java
import java.util.*;
import javax.swing.*;
public class Isbn {
    public static void main (String arg[]){
        Scanner input = new Scanner (System.in);
        int i, sum=0;
        int a[] = new int [10];
        String keep ="";
        for (i=1; i<=9; i++){
            System.out.print ("Enter value for number "+i+"=");
            a[i-1] = input.nextInt();
            keep+=a[i-1];
            sum+=a[i-1]*i;
        }
        int r = sum%11;
        if (r==10)
            System.out.print ("ISBN is : = "+keep+"x");
        else
            System.out.print ("ISBN is : = "+keep+r);
      }
    }

Loading
Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Flying Twitter Bird Widget By ICT Sparkle