Question
C++ program. Introduction : This assignment helps you to reinforce the topics discussed in the class including a) Relational operators, Boolean operators, data comparison b)
C++ program.
Introduction: This assignment helps you to reinforce the topics discussed in the class including
a) Relational operators, Boolean operators, data comparison
b) Selection
c) Repetition
d) And problem solving using selection and repetition
check:
a) The correctness of your program/solution
b) Variable naming (self describing)
c) Identification of proper data type
d) Appropriate commenting and Indentation.
Credit Card Number Verification Program:
For example, say the card number is 1234 5678 6789 1235 and its visa card. To validate it, first add all the digits 1+2+3+4+ 5+6+7+8+ 6+7+8+9 +1+2+3+5 = 77 then get mod 10 of 77 (77%10 = 7) Since its not zero, this is not a valid visa card number Write a C++ program that reads the card type and the card number and then determine if the card number entered is a valid card number. First your program should ask if the credit card is MasterCard or visa card. Then ask the 16 digit credit card number. Then add all the digits in the credit card number and get the modulo 10. If the modulo 10 of the summation of all the digits is zero, then its valid visa card. If the modulo 10 of the summation of all the digits is 1 then its valid MasterCard. Otherwise, the number customer has entered is an invalid card number.
Requirements:
You need to read the card number as a string. Then, use a loop to extra each digit from the string to add them. While entering a card number, you need to have a space between each four digit segment in the card number. Here are some of the constructs that my help. - You can use the substr method of a string to extract each digit as a string - The following method can be used to convert a string into an integer o string myString = "5"; o int value = atoi(myString.c_str())
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started