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
Who was making the high-pitched growling noise that Francisco hears?
Gwar [14]

The high-pitched growling noise that Francisco hears is due to mating call of male midshipman fish or 5G.

<h3>What is the  hum about?</h3>

The Hum is known to be a kind of unexplained happenings that has brought a lot of irritations to people. It is known to be a high-pitched noise that brought a lot of scientific theories.

Studies has shown that the high-pitched growling noise that Francisco hears is as a result of  mating call of male midshipman fish or 5G.

Learn more about noise from

brainly.com/question/2278957

8 0
2 years ago
Whats the size of a short bond paper in microsoft word?
poizon [28]
I believe the size is 8.5x11
7 0
3 years ago
Should you ever force a CPU into<br>its socket?​
tatyana61 [14]

Answer:

no you should not force a cpu into its socket.

Explanation: on an intel platform the pins are on the motherboard, therefore if you force it in it will damage the pins on the motherboard, and on AMD the pins are on the cpu itself so you can damage the extremely fragile pins on it, you can not shock your cpu however like the other answer.

7 0
3 years ago
The file extensions .webm, .m4v, and .ogv are used for:
Angelina_Jolie [31]
Audio and video files
5 0
3 years ago
Here is something cool
makkiz [27]
Cool beans s s s s s s s s
4 0
3 years ago
Read 2 more answers
Other questions:
  • Earthquakes with magnitudes between 1.0 and 2.9 on the Richter scale are
    11·1 answer
  • Which form of Internet access currently uses a technology called 4G?
    15·2 answers
  • In the Dread Pirate Roberts case, U.S. Ulbricht, 31 F. Supp. 3D 54D (S.D.N.Y. 2014), one of the issues that the court addressed
    10·1 answer
  • When completing an application what color ink do you use
    8·2 answers
  • In a set associative cache memory, if the number of ways (lines) in a set is doubled while keeping the cache size and line size
    13·1 answer
  • This is not homework but how do you fix this I’ve tried everything
    9·1 answer
  • On an unweighted scale, a grade of A is worth _____ points
    7·1 answer
  • Your job as a researcher for a college is going well. You have gained confidence and skill at pulling data and you are not makin
    13·1 answer
  • How do I change my PATH?
    7·2 answers
  • What are the three parts of a camera
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!