I need help with this last project! Credit Card Program!

This is a discussion on I need help with this last project! Credit Card Program! within the C++ Programming forums, part of the General Programming Boards category; the account number to be validated. Once again, I am no longer trying to get a degree in this field ...

  1. #1
    Registered User
    Join Date
    Sep 2008
    Posts
    9

    Unhappy I need help with this last project! Credit Card Program!

    the account number to be validated.


    Once again, I am no longer trying to get a degree in this field but I really need to pass the class. Help would be very generous!
    Last edited by ClearSights; 10-27-2008 at 12:31 PM.

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    What have you tried and what are you having trouble with?

  3. #3
    Registered User
    Join Date
    Sep 2008
    Posts
    9
    Num = ccnum

    Count = 0

    While num > 0

    Count++

    Digit = num % 10 // get last digit

    If count % 2 == 1

    Total += digit

    Else

    Digit2 = digit * 2 //Preserve the value of digit

    If digit2 > 9

    Digit2 = 1 + digit2 % 10
    end if

    total += digit2

    end if

    Num /=10 // strips off last digit

    End while

    If digit = 6

    Type = “Discover”

    Else if digit = 5

    Type = “Mastercard”

    Else if digit = 4

    Type = “Visa”

    Else

    Type = “Unknown”

    If total % 10 = 0

    Card is valid

  4. #4
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    Ok. Write that in C++, and make sure to indent it.

  5. #5
    Registered User
    Join Date
    Sep 2008
    Posts
    9
    Code:
    Num = ccnum
    
    Count = 0
    
    While num > 0
    
        Count++
    
         Digit = num % 10    // get last digit
    
        If count % 2 == 1
    
             Total += digit
    
        Else
    
             Digit2 = digit * 2   //Preserve the value of digit
    
             If digit2 > 9
    
                  Digit2 =  1 + digit2 % 10
             end if
    
              total += digit2
    
       end if
    
        Num /=10        // strips off last digit
    
    End while
    
    If digit = 6
    
       Type = “Discover”
    
    Else if digit = 5 
    
       Type = “Mastercard”
    
    Else if digit = 4
    
      Type = “Visa”
    
    Else
    
       Type = “Unknown”
    
    If total % 10 = 0
    
       Card is valid

  6. #6
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Alright, some indentation, and code tags are a good start. Now you just have to change from pseudocode to C++.

  7. #7
    Registered User
    Join Date
    Sep 2008
    Posts
    9
    Can anyone help me with changing it to C++? I really have no idea.

  8. #8

  9. #9
    Registered User
    Join Date
    Sep 2008
    Posts
    9
    Could someone please just help me? Even to get started

  10. #10
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    What have you done so far. It's no point in someone here giving you advice on something you already have done, neither does it help to give advice on what you absolutely don't understand because you haven't got that far.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  11. #11
    Registered User
    Join Date
    Sep 2008
    Posts
    9
    I have done the pseuocode but I need it in C++, Im not trying to learn C++, I had a class on it but I decided programming is not for me so I changed but I still need to pass it and its very challenging, I just need this in C++.

  12. #12
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    So you need to translate your pseudo-code to C++, and you have ABSOLUTELY NO IDEA how to go about that, is that what you are saying?

    Did you look at the links by robwhit?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  13. #13
    Hail to the king, baby. Akkernight's Avatar
    Join Date
    Oct 2008
    Location
    Faroe Islands
    Posts
    717
    He wants someone with the skill and generosity to do the code for him 'cause he doesn't want to learn C++ and he has to finish that thing for school. Or that's how I understand it :P
    Currently research OpenGL

  14. #14
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by Akkernight View Post
    He wants someone with the skill and generosity to do the code for him 'cause he doesn't want to learn C++ and he has to finish that thing for school. Or that's how I understand it :P
    I think you are right. I just wanted to get the original poster to say that...

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  15. #15
    Registered User
    Join Date
    Oct 2008
    Posts
    3

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need Help With a BlackJack Program in C
    By Jp2009 in forum C Programming
    Replies: 15
    Last Post: 03-30-2009, 11:06 AM
  2. Simple Blackjack Program
    By saber1357 in forum C Programming
    Replies: 1
    Last Post: 03-28-2009, 04:19 PM
  3. Segmentation Fault - aaaaaaaah!
    By yogibear in forum C Programming
    Replies: 6
    Last Post: 10-01-2007, 04:21 AM
  4. Replies: 5
    Last Post: 09-14-2006, 10:47 PM
  5. having problems with my card program
    By mac025 in forum C Programming
    Replies: 4
    Last Post: 01-31-2006, 04:26 PM

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