answer.
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
stiv31 [10]
2 years ago
6

In this module you learned about searching, sorting and algorithms in C++ and how to implement these elements in your C++ progra

ms. 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.
Engineering
1 answer:
alisha [4.7K]2 years ago
3 0

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

Answer:

// 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;

}

You might be interested in
True or False: Drag and tailwind are examples of a contact force.<br> tyy guyss
zloy xaker [14]

Answer:

False

Explanation:

8 0
2 years ago
A shopaholic has to buy a pair of jeans , a pair of shoes l,a skirt and a top with budgeted dollar.Given the quantity of each pr
fredd [130]

Answer:

you might be facing some difficulty in observing this point of division between your question and me

0 0
2 years ago
A rectangular tank is filled with water to a depth of 1.5 m. Its longest side measures 2.5 m. What is the moment of the force ab
marishachu [46]

Answer:

The correct answer is option 'c': 13.8 kNm

Explanation:

We know that moment of a force equals

Moment=Force\times Arm

The hydro static force is given by Force=Pressure\times Area

We know that the hydrostatic pressure on a rectangular surface in vertical position is given by Pressure=\rho \times g\times h_{c.g}

For the given rectangular surface we have h_{c.g}=\frac{h}{2}=\frac{1.5}{2}=0.75m

Thus applying the values we get force as

Force=1000\times 9.81\times 0.75\times 1.5\times 2.5=27.59kN

This pressure will act at center of pressure of the rectangular plate whose co-ordinates is given by h/3 from base

Thus applying the calculated values we get

Moment=27.59\times \frac{1.5}{3}=13.8kN.m

8 0
2 years ago
Finally you will implement the full Pegasos algorithm. You will be given the same feature matrix and labels array as you were gi
Diano4ka-milaya [45]

Answer:

In[7] def pegasos(feature_matrix, labels, T, L):

   """

   .

   let learning rate = 1/sqrt(t),

   where t is a counter for the number of updates performed so far       (between 1   and nT inclusive).

Args:

       feature_matrix - A numpy matrix describing the given data. Each row

           represents a single data point.

       labels - A numpy array where the kth element of the array is the

           correct classification of the kth row of the feature matrix.

       T -  the maximum number of times that you should iterate through the feature matrix before terminating the algorithm.

       L - The lamba valueto update the pegasos

   Returns: Is defined as a  tuple in which the first element is the final value of θ and the second element is the value of θ0

   """

   (nsamples, nfeatures) = feature_matrix.shape

   theta = np.zeros(nfeatures)

   theta_0 = 0

   count = 0

   for t in range(T):

       for i in get_order(nsamples):

           count += 1

           eta = 1.0 / np.sqrt(count)

           (theta, theta_0) = pegasos_single_step_update(

               feature_matrix[i], labels[i], L, eta, theta, theta_0)

   return (theta, theta_0)

In[7] (np.array([1-1/np.sqrt(2), 1-1/np.sqrt(2)]), 1)

Out[7] (array([0.29289322, 0.29289322]), 1)

In[8] feature_matrix = np.array([[1, 1], [1, 1]])

   labels = np.array([1, 1])

   T = 1

   L = 1

   exp_res = (np.array([1-1/np.sqrt(2), 1-1/np.sqrt(2)]), 1)

   

   pegasos(feature_matrix, labels, T, L)

Out[8] (array([0.29289322, 0.29289322]), 1.0)

Explanation:

In[7] def pegasos(feature_matrix, labels, T, L):

   """

   .

   let learning rate = 1/sqrt(t),

   where t is a counter for the number of updates performed so far       (between 1   and nT inclusive).

Args:

       feature_matrix - A numpy matrix describing the given data. Each row

           represents a single data point.

       labels - A numpy array where the kth element of the array is the

           correct classification of the kth row of the feature matrix.

       T -  the maximum number of times that you should iterate through the feature matrix before terminating the algorithm.

       L - The lamba valueto update the pegasos

   Returns: Is defined as a  tuple in which the first element is the final value of θ and the second element is the value of θ0

   """

   (nsamples, nfeatures) = feature_matrix.shape

   theta = np.zeros(nfeatures)

   theta_0 = 0

   count = 0

   for t in range(T):

       for i in get_order(nsamples):

           count += 1

           eta = 1.0 / np.sqrt(count)

           (theta, theta_0) = pegasos_single_step_update(

               feature_matrix[i], labels[i], L, eta, theta, theta_0)

   return (theta, theta_0)

In[7] (np.array([1-1/np.sqrt(2), 1-1/np.sqrt(2)]), 1)

Out[7] (array([0.29289322, 0.29289322]), 1)

In[8] feature_matrix = np.array([[1, 1], [1, 1]])

   labels = np.array([1, 1])

   T = 1

   L = 1

   exp_res = (np.array([1-1/np.sqrt(2), 1-1/np.sqrt(2)]), 1)

   

   pegasos(feature_matrix, labels, T, L)

Out[8] (array([0.29289322, 0.29289322]), 1.0)

6 0
2 years ago
A suspension of Bacillus subtilis cells is filtered under constant pressure for recovery of protease. A pilot-scale filter is us
sattari [20]

The answer & explanation for this question is given in the attachment below.

7 0
2 years ago
Other questions:
  • What is the physical significance of the Reynolds number?. How is defined for external flow over a plate of length L.
    13·1 answer
  • Which of the following is NOT true about hydraulic valves? A. Directional control valves determine the path of a fluid in a give
    10·1 answer
  • A pitfall cited in Section 1.10 is expecting to improve the overall performance of a computer by improving only one aspect of th
    6·1 answer
  • Some states have osha programs, but you should always defer to the federal program.
    8·2 answers
  • Pipe (2) is supported by a pin at bracket C and by tie rod (1). The structure supports a load P at pin B. Tie rod (1) has a diam
    15·1 answer
  • Given a 5x5 matrix for Playfair cipher a. How many possible keys does the Playfair cipher have? Ignore the fact that some keys m
    6·1 answer
  • Current density is given in cylindrical coordinates as J = −106z1.5az A/m2 in the region 0 ≤ rho ≤ 20 µm; for rho ≥ 20 µm, J = 0
    13·1 answer
  • The following passage contains a fragment. Select the correct revision. Presley took the exuberance of gospel and added the freq
    7·1 answer
  • 6.28 A six-lane freeway (three lanes in each direction) in rolling terrain has 10-ft lanes and obstructions 4 ft from the right
    11·1 answer
  • A thin, flat plate that is 0.2 m × 0.2 m on a side is oriented parallel to an atmospheric airstream having a velocity of 40 m/s.
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!