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 chip that wakes up the computer system
bezimeni [28]

Explanation:

The wake-up receiver is an ultra-low power chip that continuously looks out for a specific radio signal, called a wake-up signature, that tells it when to wake up the main device

4 0
3 years ago
[80 points] Fill in the missing word.
AVprozaik [17]

Answer:

except

you can use github copilot for this  question

8 0
2 years ago
Design a program that will receive a valid time in the 24-hour format (e.g. 2305) and convert to its equivalent 12-hour format (
coldgirl [10]

Answer:

import java.io.*;

public class Main

{

  public static void main(String[] args) throws IOException {

      BufferedReader bufferObject=new BufferedReader(new InputStreamReader(System.in));

      String stringObject=bufferObject.readLine();

      while(!stringObject.equals("99:99AM")){

      System.out.println(convertedTime(stringObject));

      stringObject=bufferObject.readLine();

      }

  }

  public static String convertedTime(String stringObject){

  String s=stringObject.substring(stringObject.length()-2);

  String[] timeObject=stringObject.substring(0,5).split(":");

  if(s.equals("AM")){

  if(timeObject[0].equals("12")) return "00"+timeObject[1];

  else return timeObject[0]+timeObject[1];

  }

  else{

  if(timeObject[0].equals("12")) return "12"+timeObject[1];

  else{

  int hours=Integer.valueOf(timeObject[0]);

  timeObject[0]=String.valueOf(12+hours);

  return timeObject[0]+timeObject[1];

  }

  }

 

  }

}

Explanation:

  • Inside the main method run a while loop until stringObject is not equal to the string "99:99AM".
  • Call the convertedTime method and display the results.
  • Use the same hours and minutes except for 12th hour If the time is in AM.
  • Use "00" instead of 12, if it is 12th hour.
  • Add hours to 12, if the time is in PM and don't change anything in case of 12.
8 0
3 years ago
In end game, should you drink a chug jug just to get an extra 25-50 shield?
antiseptic1488 [7]
Yes, It's important to do that. The more shield you have the more you stay alive between 1v1s 

Hope this helps!
3 0
4 years ago
What do you mean by Data Types? Give Examples. <br>Ms Access question​
Anika [276]

Answer:

This answer is quite late, but data types are basically categories that differentiate stuff in python.

A few examples would be:

String - Anything that has single or double-quotes around it. The input( ) function automatically returns a string, unless changed.

Int - An integer. Any whole number.

Float - Any decimal number.

List - a variable in which you can store multiple different elements. (Strings, integers, floats, tuples, lists, etc...)

Also, sorry if my English isn't perfect. English isn't my first language.

Explanation:

Don't know. Just some stuff I remember from my python class. ∞

3 0
3 years ago
Other questions:
  • Your computer is once again out of hard drive and you want to see which folders are consuming the most space on your drive. Whic
    15·1 answer
  • What is looping? the rerecording of sound first recorded on set the recording of sound on set the process of combining different
    11·1 answer
  • What is the only language a microprocessor can process directly but most programmers almost never write programs in this code? Q
    12·2 answers
  • Why do we need IP Addresses in order for the Internet to function properly?
    7·1 answer
  • What a true portrait reveal
    7·1 answer
  • A small network used for communication between personal computing devices is known as?
    8·1 answer
  • Select the correct answer from each drop-down menu.
    8·2 answers
  • Redundancy can be implemented at a number of points throughout the security architecture, such as in ________. Group of answer c
    12·1 answer
  • _______________ ________________ have human editors that evaluate, select, and organize websites into a hierarchy of categories.
    11·1 answer
  • When power is completely removed from your computer
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!