1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
vodomira [7]
3 years ago
9

Write a program that lets the user enter a charge account number. Be sure to include comments throughout your code where appropr

iate. The program should determine if the number is valid by checking for it in the following list of valid account number
5658845, 4520125, 7895122, 8777541, 8451277, 1302850, 8080152,4562555, 5552012, 5050552, 7825877, 1250255, 1005231, 6545231,3852085, 7576651, 7881200, 4581002
The list of numbers above should be initialized in a single– dimensional array. A simple linear search should be used tolocate the number entered by the user. If the user enters a numberthat is in the array, the program should display a message sayingthat the number is valid. If the user enters a number that is notin the array, the program should display a message indicating thatthe number is invalid.
Computers and Technology
1 answer:
coldgirl [10]3 years ago
5 0

Answer:

#include <iostream>

using namespace std;

int main(){

   int accountnum;

int\ accountnumbers[18] = \{5658845, 4520125, 7895122, 8777541, 8451277, 1302850, 8080152,4562555, 5552012, 5050552, 7825877, 1250255, 1005231, 6545231,3852085, 7576651, 7881200, 4581002\};

   cout<<"Account Number: ";

   cin>>accountnum;

   int arrlength =*(&accountnumbers + 1) - accountnumbers;

   int exist = 0;

   for(int i =0;i<arrlength;i++){

       if(accountnum == accountnumbers[i]){

        cout<<"Valid account number";

        exist = 1;

        break;

       }

   }

   if(exist == 0)

       cout<<"Invalid account number";

     

   return 0;

}

Explanation:

The solution is implemented in C++ (See attachment)

This declares user account number as integer

  int accountnum;

This initializes the list of account numbers to an array

int\ accountnumbers[18] = \{5658845, 4520125, 7895122, 8777541, 8451277, 1302850, 8080152,4562555, 5552012, 5050552, 7825877, 1250255, 1005231, 6545231,3852085, 7576651, 7881200, 4581002\};

This prompt user for account number

   cout<<"Account Number: ";

Here, user inputs the account number

   cin>>accountnum;

This calculates the length of the array

   int arrlength =*(&accountnumbers + 1) - accountnumbers;

This initializes a check variable to 0

   int exist = 0;

This iterates through the array

   for(int i =0;i<arrlength;i++){

This checks for valid account number.

       if(accountnum == accountnumbers[i]){

If true, the following message is printed

        cout<<"Valid account number";

The check variable is updated to 1, which implies that the account number is valid

        exist = 1;

And the loop is terminated

        break;

       }

   }

If the check variable is not updated, then the account number is invalid

<em>    if(exist == 0)</em>

<em>        cout<<"Invalid account number";</em>

     

   return 0;

Download cpp
You might be interested in
Terry came into work and turned on his computer. During the boot process, the computer shut down. When he tried again, the compu
krok68 [10]

el cable SATA porque sirve para la transferencia de datos entre la placa base y algunos dispositivos de almacenamiento como la unidad de disco duro (donde generalmente se instala el sistema operativo)

3 0
3 years ago
How do I make my kali Linux faster in my virtual box?
vagabundo [1.1K]
Not sure to be honest
7 0
3 years ago
A (n) ___ system can help a business alleviate the need for multiple information systems.
BigorU [14]

Answer:

Enterprise Resource Planning

Explanation:

ERP

3 0
3 years ago
ASAP PLZ!!! Select the correct answer.
rodikova [14]

Answer:

after data is appropriately processed, transformed and stored, it is subject to data mining. This step covers data analysis methods including parametric and non-parametric methods, and machine-learning algorithms. A good starting point for data mining is data visualization.

Explanation:

3 0
3 years ago
Read 2 more answers
What is the value of the following expression? (false || (4-3 &amp;&amp; 6))
NISA [10]

Answer:

true

Explanation:

The operator '||' is called the OR operator. it is used in between the two Boolean values.

OR operator has four possible values:

First Boolean is TRUE and second Boolean is TRUE, result will be TRUE.

First Boolean is TRUE and second Boolean is FALSE, result will be TRUE.

First Boolean is FALSE and second Boolean is TRUE, result will be TRUE.

First Boolean is FALSE and second Boolean is FALSE, result will be FALSE.

consider the expression:

(false || (4-3 && 6))

the second expression (4-3 && 6) gives Boolean TRUE, because their is no point for condition false.

so, (false || True) gives TRUE result.

7 0
4 years ago
Read 2 more answers
Other questions:
  • Grace is the sub-editor in a business firm. which feature of a word processing program would she use to make her changes visible
    14·1 answer
  • How do smart watches affect the business and its position in the global marketplace?
    12·2 answers
  • What is the definition of framerate?
    7·1 answer
  • Luchen Modo, a software development firm in Asia, launched a new software for smartphones that allowed users to remotely control
    11·1 answer
  • You have a screen and a pen, which is an instance of the Turtle class.
    13·2 answers
  • Have a good christmas. this might not be homework, but i just want everyone to have a good week
    6·2 answers
  • Anna has a physical mobility difference, and she uses virtual reality to complete her exercises. To use virtual reality, Anna ne
    7·1 answer
  • Describe the layout of an article on Wikipedia​
    7·1 answer
  • 4:when a computer is on it is
    8·1 answer
  • Passing an argument by ___ means that only a copy of the arguments value is passed into the parameter variable and not the addrt
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!