Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello! I am completely new to coding and need some help with C++. I have a project due for class soon and I need some

Hello! I am completely new to coding and need some help with C++.

I have a project due for class soon and I need some assistance in how to build the code along with explanations for each step. Thank you!

image text in transcribedimage text in transcribed

Problem Statement Write a program that performs Credit Card Number Check. Your program should repeatedly ask the user to input an 8 -digit number to check if it is valid, until the user enters 1 to quit. (Please note that for simplicity, now you can assume the user will always enter 8-digit numbers to check except for quitting the program with 1. In the coming week, we will learn how to handle the user input validation). Please note that this Lab assignment is from the Programming Project 4.22.21 of the ZyBook. Your program will implement the following algorithm: The last digit of a credit card number is the check digit, which protects against transactions errors such as an error in a single digit or switching two digits. The following method is for numbers with 8 digits: - Starting from the rightmost digit, form the sum of every other digit. For example, if the credit card number is 43589795 . Then you form the sum 5+7+8+ 3=23 - Double each of the digits, which were not included in the preceding step. Add all digits of the resulting numbers. For example, with the number given above, doubling the digits, starting with the next-to-last one, yields 1818108. Adding all digits in these values yields 1+8+1+8+1+0+8= 27. - Add the sums of the two preceding steps. If the last digit of the result is 0 , the number is valid. In our case, 23+27=50, so the number is valid. After the user supplies an 8-digit number, your program should implement the above algorithm, then print out whether the number is a valid credit card number or not. If it is not valid, you should print out the value of the check digit that would make the number valid. The following show some examples of running your program: Sample output 1: Please enter the 8 -digit credit card number (enter 1 to quit) : 1 Thank you for using "Credit Card Number Validation"! Sample output 2: Pleage enter the 8-digit credit card number enter - 1 to quit) : 43589795+ Number is valid. Pleage enter the 8-digit credit card number enter 1 to quit) : 435897944 Number is invalid. Check digit should have been 5 Pleage enter the 8-digit credit card number (enter 1 to quit) : 43589793+ Number is invalid. Check digit should have been 5 Pleage enter the 8 -digit credit card number (enter 1 to quit) : 43589791 Number is invalid. Check digit should have been 5 Pleage enter the 8-digit credit card number (enter -1 to quit) : 438897954 Number is invalid. Check digit ahould have been 9

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Current Trends In Database Technology Edbt 2006 Edbt 2006 Workshops Phd Datax Iidb Iiha Icsnw Qlqp Pim Parma And Reactivity On The Web Munich Germany March 2006 Revised Selected Papers Lncs 4254

Authors: Torsten Grust ,Hagen Hopfner ,Arantza Illarramendi ,Stefan Jablonski ,Marco Mesiti ,Sascha Muller ,Paula-Lavinia Patranjan ,Kai-Uwe Sattler ,Myra Spiliopoulou ,Jef Wijsen

2006th Edition

3540467882, 978-3540467885

More Books

Students also viewed these Databases questions

Question

Compose the six common types of social business messages.

Answered: 1 week ago

Question

Describe positive and neutral messages.

Answered: 1 week ago