|
help, I am new with c++
This my next Program and I would like some help how to start it.
A local bank has instituted a new credit system and would like to have account numbers that are self-checking in order to have some protection against fraud and clerical errors. They have devised a system a follows:
The account numbers will be nine digits long and the ninth digit(rightmost)can be calculated by either adding, subtracting, or multiplying all of the preceding digits and finfind the rightmost digit of the result. If the two righmost digits match, the account numbers is valid.
In the operation code(the first digit), 1 is addition, 2 is subtraction, and 3 is multiiplication. Any other digit in this position is incorrect.
Your job is to write a program that will check the validity of an account number that has been sent to the bank as part of its daily transaction.
INPUT: a nine-digit account number.
OUPUT: Echo print the input, followed by account status.
(Either VALID, INVALID, or OPERATION CODE ERROR)
EXAMPLE: 123456786
1+2+3+4+5+6+7+8=36
6 is the rightmost digit in both the account number and the
result of the operation. Therefore, the account number is
VALID.
EXAMPLE: 312131413
3*1*2*1*3*1*4*1=72
The righmost digit of the result of the operation is 2, but
the rightmost digit of the account number is 3. This account
number is INVALID.
#include<iostream>
#include<fstream>
using namespace std;
int main()
{
char ch;
ifstream ifout;
ofstream ifout;
int val, char number[9];
ifout.open("data.txt",ios::in);//I have to creat data.txt file also//
if(!ifout)
{
cout<<"Error: Coul not openfile" <<endl;
exit(1);
)
Cout << "Enter a nine digit"<<endl;
I am having problems with the ( for loop ) I don't know how to have the user to Enter the 9 digit nubers and then add them or subtract them together.
if some can help, that would be nice.
|