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
A(n) ____ allows others besides the manufacturer to develop software to run on the system or device.
RideAnS [48]

Answer:

Application Programming Interface.

Explanation:

Application Programming Interface(API) is a collection of function, routines, procedures and the protocol which are used create a software application.The main role of API is that it defined or specified how the components of software will interact.

The objective of the Application Programming Interface that it the manufacturer or develop software that is running on system or device. The advantage of using the Application Programming Interface is that we can develop a better program in a very manner by using the API.

5 0
4 years ago
The direction of a ratchet is reversed by _______________________.
ankoles [38]

Answer:

You can reverse the direction of a ratchet by hitting with an equal or higher amount of force it came at you with.

Explanation:

6 0
2 years ago
Your essay is due tomorrow and you don't have time to write it. You decide to buy an essay online. You've paid for it, so it can
viva [34]

Answer:

false

even though you have paid for it , you still didn't write it by yourself, there for it will still be seen as plagiarism.......hope this helps

4 0
3 years ago
Nina aspires to be a digital media specialist. What should Nana be familiar with in order to pursue this career?
brilliants [131]

computer science? maybe im not sure?

4 0
3 years ago
Read 2 more answers
The procedure in which a film simulation of a skilled performance is stopped and the person is asked to indicate the outcome of
astraxan [27]
Your answer is:
temporal occlusion procedure

I hope this helps! :)
6 0
3 years ago
Other questions:
  • Where would be the most likely place to find the keyboard combination used to toggle a keyboard backlight on or off?
    8·1 answer
  • A computer connected to the internet that asks for data is a ________. aggregator surrogate server client
    6·1 answer
  • Which company is credited with solving a problem by creating a program that could work on all computers?
    11·1 answer
  • How to change font size and style and add a table when creating a webpage?
    6·1 answer
  • The ________ is the heart of the operating system and controls its most critical processes.
    9·1 answer
  • A researcher wants to do a web-based survey of college students to collect information about their sexual behavior and drug use.
    7·1 answer
  • What is the process of designing green buildings called
    9·2 answers
  • To insert text from a separate file into your Word document
    10·1 answer
  • What best describes the computer's BIOS (basic input-output system)?
    5·1 answer
  • Which line is most likely an error? A-“hello” B-hello C-“100” D-100
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!