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
Ber [7]
3 years ago
5

For this project you have been asked to write a program for a local store owner. The store owner wants to keep a record of the n

ame of his customers as well as the money they spend at each visit. Your program will dynamically allocate two arrays one to store the names and another one to store the amount of the purchase. The size of both arrays will be dynamically determined from the value entered by the user. Your program should allow the user to enter name-purchase pairs. For each customer entered to the store, the user types the customer’s name followed by the customer’s purchase amount. After the user enters all the customers, your program should display the list of all customers with their purchase amount. You will also need to create a function to calculate the average of the purchases by all the customers. Note: Use pointer notation rather than array notation. Also make use of the newoperator to dynamically allocate memory.Input validation: don’t accept negative amount and empty strings (e.g., "", " ").Both display and calculate should be functions. To help you out, here are their prototypes:void display(string*, double*, int); double calculate(double*, int); void sort(string*, double*, int);Check the PA4_Demo video to see a sample runof the program

Computers and Technology
1 answer:
elena55 [62]3 years ago
7 0

Answer:

see explaination

Explanation:

#include <iostream>

using namespace std;

void display (string* name, double* purchase, int n)

{

cout<<"Name Purchase"<<endl;

cout<<"------------------------"<<endl<<endl;

for(int i=0;i<n;i++)

{

cout<<name[i]<<" "<<purchase[i]<<endl;

}

}

double calculate(double* purchase,int n)

{

double avg, sum=0;

for(int i=0;i<n;i++)

{

sum=sum+purchase[i];

}

avg=sum/n;

return avg;

}

int main()

{

int n;

cout<<"How many customer will you enter? "<<endl;

cin>>n;

string *name=new string[n];

double *purchase=new double[n];

for(int i=0;i<n;i++)

{

cout<<"Enter the customer"<<i+1<<"'s name: "<<endl;

cin>>name[i];

cout<<"Enter that customer's purchase: "<<endl;

cin>>purchase[i];

}

display(name, purchase,n);

double avg=calculate(purchase,n);

cout<<"Average purchase: "<<avg<<endl;

}

See attachment for the screenshot

You might be interested in
What are some cloud storage devices?​
ryzh [129]

i believe some are google docs, apple icloud, xdrive, MediaMax, and Strongspace

6 0
3 years ago
What is internet? explain help pliz​
m_a_m_a [10]

The Internet, sometimes called simply "the Net," is a worldwide system of computer networks -- a network of networks in which users at any one computer can, if they have permission, get information from any other computer (and sometimes talk directly to users at other computers).

3 0
3 years ago
Host B is sending an email intended for the user on Host A to the email server. What protocol is being used to send the message
Lynna [10]

Answer:

I think that part A is correct option

6 0
4 years ago
Calculate the time necessary to perform a multiply using the approach described in the text (31 adders stacked vertically) if an
Rudiy27

The time that will be used to perform a multiplication using the approach is 28 time units.

<h3>How to calculate time taken?</h3>

From the information given, the following can be noted:

A = 8 (bits wide)

B = 4 time units.

The multiplication will be performed based on the adder stack. Since A = 8, then, A - 1 = 8 - 1 = 7.

Now, the time taken will be:

= 7 × B

= 7 × 4tu

= 28 tu

In conclusion, the correct option is 28 time units.

Learn more about time taken on:

brainly.com/question/10428039

5 0
2 years ago
There are several categories of utility programs that were discussed in this unit. For this item, list one. In one to three sent
Zolol [24]

Answer:

Antivirus

Explanation:

The antivirus software is a utility program and what it basically does include: (1) detecting of virus on the computer system (2) bring to the notice of the computer user, the presence of virus on the system.

An example is Avast Antivirus.

6 0
3 years ago
Other questions:
  • Which of the following is NOT an example of systems software?
    9·1 answer
  • Lin is booting up his computer, and during the boot process, the computer powers down. After several unsuccessful attempts to bo
    10·1 answer
  • why do programs include keyboard shortcuts for certain actions? do you prefer the mouse or the keyboard/ why?
    7·1 answer
  • Which of the following refers to a combination of hardware and software that ensures only authorized individuals gain entry into
    11·1 answer
  • On CLIENT3, open Windows Explorer as Administrator. Open properties for C:\Program Files and select the Security tab to view the
    12·1 answer
  • Write a program that implement a bubble sort ?
    5·1 answer
  • What is the primary means by which attackers infect computers with these attacks? How do these attacks commonly occur?
    8·1 answer
  • The four smallest numbers (40 points) Write an ANNA assembly program (smallest_four.ac) that finds the four smallest numbers ent
    11·1 answer
  • Determine the distance between point (x1, y1) and point (x2, y2), and assign the result to points Distance. The calculation is:
    12·1 answer
  • Write the simulate method, which simulates the frog attempting to hop in a straight line to a goal from the frog's starting posi
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!