elrodkaitlynn2965
20.04.2020 •
Engineering
In this module you learned about searching, sorting and algorithms in C++ and how to implement these elements in your C++ programs. In this assignment you will implement your knowledge of searching, sorting and algorithms for charge account validation system. Write a program that lets the user enter a charge account number. Be sure to include comments throughout your code where appropriate. The program should determine if the number is valid by checking for it in the following list of valid account numbers:
814942053331743080098675596395269814449539938719751047262931356428263717502196086650316483824195904578589971890467499412545408Initialize a one-dimensional array with these values. Then use a simple linear search to locate the number entered by the user. If the user enters a number that is in the array, the program should display a message indicating that the account number is valid. If the user enters a number not in the array, the program should display a message indicating it is invalid.Next, using the same one-dimensional array, use a bubble-sort to put the array in order and perform a binary search to locate the number entered by the user. If the user enters a number that is in the array, the program should display a message indicating that the account number is valid. If the user enters a number not in the array, the program should display a message indicating it is invalid.
Solved
Show answers
More tips
- S Society and Politics Why are thugs called gopniks ? A fascinating journey through Russian subculture...
- A Animals and plants Want a Perfect Lawn? Learn How to Plant Grass the Right Way...
- A Animals and plants How to Properly Care for a Pet Decorative Rabbit at Home?...
- C Computers and Internet How to Check the Speed of My Internet?...
- H Health and Medicine 10 Ways to Cleanse Your Colon and Improve Your Health...
- W Work and Career How to Write a Resume That Catches the Employer s Attention?...
- C Computers and Internet Е-head: How it Simplifies Life for Users?...
- F Family and Home How to Choose the Best Diapers for Your Baby?...
- F Family and Home Parquet or laminate, which is better?...
- L Leisure and Entertainment How to Properly Wind Fishing Line onto a Reel?...
Answers on questions: Engineering
- E Engineering Steam in a heating system flows through tubes whose outer diameter is 5 cm and whose walls are maintained at a temperature of 130 c. circular aluminum alloy 2024-t6 fins (k = 186...
- M Mathematics Given triangle ABC, select all of the true statements. Right triangle A B C. Angle B is the right angle. A. sin A = sin C B. sin A = cos C C. cos A = cos C D. sin A = tan C E. cos...
- M Mathematics Determine the slope of the line that contains the given points. T(–6, 6), V(8, 8)...
- S Social Studies Based on sociologist Robert Merton s typology of prejudice and discrimination, may have no personal prejudice but still engage in discriminatory behavior because of peer group pressure...
Ответ:
Question is not well presented:
The search strings in the question are not well formatted.
First thing, I'll arrange the account number in order of 7;
Meaning that the length of each account number is 7
8149420 5333174 3080098 6755963 9526981 4449539 9387197 5104726 2931356 4282637 1750219 6086650 3164838 2419590 4578589 9718904 674994 12545408
// This program is written in C++ Programming Language
// Comments are used for explanatory purpose
// Program starts here
#include <iostream>
using namespace std;
// Initialise Function
int ArrayList(int[], int, int);
// Main Method starts at
int main()
{
// The list of account is 18; so, we Initialise an integer Variable to hold this value
const int acctlist = 18;
// Initialise an array to hold the account numbers
int List[acctlist] = { 8149420 5333174 3080098 6755963 9526981 4449539 9387197 5104726 2931356 4282637 1750219 6086650 3164838 2419590 4578589 9718904 674994 12545408
};
// Declare account number and search result Variables of type integer
int accountnumber, Result;
// Prompt user for account number
cout << "Enter a valid account number: ";
cin >> accountnumber;
// Determine if valid or not
Result = ArrayList(List, acctlist, accountnumber);
if(Result == -1){
cout << "Account number " << AcctNum << " is invalid.\n";}
else{
cout << "Account number " << List[Result] << " is valid\n";
}
return 0;
}
// Function starts here
int ArrayList(int list[], int size, int value)
{
int index = 0,
pos = -1;
bool seen = false;
// Check if Account number is seen in list
while (!seen && index < size)
{
if (list[index] == value)
{
seen = true;
}
pos = index;
}
index++;
}
return pos;
}
Ответ:
Sagittal cut directly down the midline
Explanation: