Like Tree2Likes
  • 2 Post By Salem

HELP!!!!!! Homework Validating ISBN w\ dashes due next week

This is a discussion on HELP!!!!!! Homework Validating ISBN w\ dashes due next week within the C Programming forums, part of the General Programming Boards category; I need to write a program that validates ISBN numbers in the that are 10 digits long with the 10 ...

  1. #1
    Registered User
    Join Date
    Oct 2011
    Posts
    24

    HELP!!!!!! Homework Validating ISBN w\ dashes due next week

    I need to write a program that validates ISBN numbers in the that are 10 digits long with the 10 th digit being the check sum digit example
    ISBN: 0-13-240416-8
    0+2*1+3*3+4*2+5*4+6*0+7*4+8*1+9*6=129
    When 129 is divide by 11 the remainder is 8
    check digit is 8.

    I have to write a program that will determine the string of characters entered only contain dash("-") and numeric characters ( in a 10 digit ISBN the dashes may be in different locations depending on the book publisher.). If characters are valid it must the calc. the check digit to determine if the ISBN is valid.

    I need to include user-written functions to.
    * validate input
    *calculate the check digit validity
    stlib. funct. for checking numeric values may also be useful.

    I have a basic idea of how to write a program in C++
    Code:
    #include <iostream>
    002
    #include <process.h>
    003
    #include <iomanip>
    004
    #include <conio.h>
    005
    #include <string>
    006
    #include <stdio.h>
    007
    #include <ctype.h>
    008
    #include <windows.h>
    009
    using namespace std;
    010
     
    011
    void gotoxy(int x, int y)
    012
    {
    013
      COORD coord;
    014
      coord.X = x;
    015
      coord.Y = y;
    016
      SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
    017
    }
    018
     
    019
    void clrscr(int x, int y)
    020
    {
    021
        COORD                      coordScreen = { x, y };
    022
        DWORD                      cCharsWritten;
    023
        CONSOLE_SCREEN_BUFFER_INFO  csbi;
    024
        DWORD                      dwConSize;
    025
        HANDLE                    hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    026
        GetConsoleScreenBufferInfo(hConsole, &csbi);
    027
        dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
    028
        FillConsoleOutputCharacter(hConsole, TEXT(' '),
    029
                                   dwConSize, coordScreen, &cCharsWritten);
    030
        GetConsoleScreenBufferInfo(hConsole, &csbi);
    031
        FillConsoleOutputAttribute(hConsole, csbi.wAttributes,
    032
                                   dwConSize, coordScreen, &cCharsWritten);
    033
        SetConsoleCursorPosition(hConsole, coordScreen);
    034
    }
    035
     
    036
    void main (void)
    037
    {
    038
        int isbn[5] = {11110, 12221, 13332, 24443, 25554};
    039
        string book_title[5] = {"Binary Kibbles and Bits", "Syntaxico", "Vitamin C++", "Surf and Turf the Web",
    040
            "Java-lin: Olympic Favorite"};
    041
        float retail[5] = {155.95, 116.75, 126.50, 125.75, 138.99};
    042
        int i = 0;
    043
        int x = 6;
    044
        int qty = 0;
    045
        int y = 0;
    046
        float total = 0.00;
    047
        string option = "t";
    048
     
    049
         
    050
     
    051
        gotoxy(10,4);
    052
        cout << "ISBN" << endl;
    053
     
    054
        gotoxy(20,4);
    055
        cout << "Title" << endl;
    056
     
    057
        gotoxy(47,4);
    058
        cout << "Price" << endl;
    059
     
    060
        gotoxy(54,4);
    061
        cout << "Qty" << endl;
    062
     
    063
        gotoxy(58,4);
    064
        cout << "Total" << endl;
    065
     
    066
        do
    067
        {
    068
         
    069
        gotoxy(10,x);
    070
        cin >> i;
    071
     
    072
        for(y = 0; y < 5; y++)
    073
        {
    074
            if(i == isbn[y])
    075
                break;
    076
            else if(i !=
    077
            {
    078
                gotoxy(10,x);
    079
                cin >> i;
    080
            }
    081
        }
    082
     
    083
        for(y = 0; y < 5; y++)
    084
        {
    085
            if(i == isbn[y])
    086
                break;
    087
        }
    088
     
    089
         
    090
        gotoxy(20,x);
    091
        cout << book_title[y] << endl;
    092
     
    093
        gotoxy(47,x);
    094
        cout << retail[y] << endl;
    095
     
    096
        gotoxy(54,x);
    097
        cin >> qty;
    098
     
    099
        total = retail[y]* qty;
    100
     
    101
        gotoxy(58,x);
    102
        cout << total << endl;
    103
     
    104
        x++;
    105
     
    106
        gotoxy(10,11);
    107
        cout << "Press t for total, or type in another ISBN number." << endl;
    108
        gotoxy(10,x);
    109
        cin >> option;
    110
        gotoxy(10,11);
    111
        clrscr(10,11);
    112
        if(option == "t");
    113
        break;
    114
     
    115
        }while(option == "t" || x < 11);
    116
     
    117
     
    118
        _getch();
    119
     
    120
    }

  2. #2
    Registered User TheBigH's Avatar
    Join Date
    May 2010
    Location
    Melbourne, Australia
    Posts
    426
    This is C++, not C. Someone will be along to move this thread shortly.
    Code:
    while(!asleep) {
       sheep++;
    }

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,335
    Someone needs to get off their ass and down to some work.

    Checking A Value In An Array - C And C++ | Dream.In.Code
    Instead of simply copy/pasting someone else's code (line numbers and all) in the hope that it will convince us that they've made a serious effort.

    You have no idea how hard I'm laughing at your ineptitude!
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. decode isbn help
    By Thegame16 in forum C Programming
    Replies: 22
    Last Post: 02-14-2011, 10:12 PM
  2. isbn number.
    By xxbleh in forum C Programming
    Replies: 4
    Last Post: 11-12-2007, 05:44 AM
  3. validate isbn
    By sal817 in forum C Programming
    Replies: 14
    Last Post: 02-27-2006, 08:39 AM
  4. e-week, networking, and a 96 hour week...
    By doubleanti in forum A Brief History of Cprogramming.com
    Replies: 9
    Last Post: 02-23-2003, 04:23 PM
  5. ISBN Project
    By Unregistered in forum C++ Programming
    Replies: 2
    Last Post: 02-13-2002, 02:53 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21