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
1) "Information systems are revolutionizing the way businesses function in the 21st century," Do you agree or disagree with this
alukav5142 [94]

Answer:

true

Explanation:

everything is computerized. banks, shopping, financial business records, ect

7 0
3 years ago
Which are technical and visual demands that need to be considered when planning a project? Choose three answers
Marina CMI [18]

Answer: Resolution or DPI, deliverables, and file types are important technical and visual demands to consider when planning a project.

Explanation: Keep in mind whether or not the project will be published in print or on the Web.

8 0
3 years ago
FTP is commonly used to __________ and __________ files to a server.
Aleks [24]

Answer:

upload; download

Explanation:

FTP (File Transfer Protocol) is an internet protocol used to upload and download a file to a server, there are some programs help us to transfer this data to a server, in some cases, we're going to need these programs to upload website files to the server like images or videos, or some websites where do you need a user and passwords to upload file by FTP

8 0
4 years ago
The _____ option will require users to have a password to access the document.
Zepler [3.9K]
The login option will require users to have to have a password to access the document
6 0
3 years ago
Read 2 more answers
To create a multiple-table form based on the âmanyâ table, tap or click the ____ button on the create tab to create a form in la
Archy [21]
Click on the blank form button. 
3 0
3 years ago
Other questions:
  • How do computers perform complicated tasks built from simple instructions?
    14·1 answer
  • 1). What is the proper name of the healing agent?
    5·1 answer
  • When Liam went to print his presentation, the boot process established the connection to the printer, sent the presentation to t
    12·1 answer
  • Cloud computing allows organizations to rent computing resources from providers instead of having their own locally managed ____
    7·1 answer
  • Do debit cards offer the highest level of fraud pretection?
    10·1 answer
  • If you give an actual answer I'll give brainliest​
    13·2 answers
  • _________________________ are the countable products resulting from a program, while ________________________ are the changes in
    9·1 answer
  • 3. Choose the statement that best describes a ray. A ray extends forever in both directions. B ray is a part of a line with two
    10·1 answer
  • Sustainable development is a goal towards which all human societies need to be moving. elaborate the statement in about 120 word
    9·1 answer
  • "Bookings are to be stored in three separate
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!