Paste
Copy
Cut


Options

This problem has been solved!

You'll get a detailed solution from a subject matter expert that helps you learn core concepts.

See Answer
  • Question: it to the standard output. For each statement, the first line should display the person's name. The following lines should list the objects they purchased along with the amount paid for each object (one object per line). Finally, the last line should print "Total: value", where value is the sum of all payments. For example, for the given inputs

    it to the standard output. For each statement, the first line should display the person's name. The following lines should list the objects they purchased along with the amount paid for each object (one object per line). Finally, the last line should print "Total: value", where value is the sum of all payments. For example, for the given inputs (payments.txt and people.txt), it should print:
    Bob
    eggs 2.5
    pen 3.5
    Total: 6
    Alice
    apple 1.5
    eggs 2
    Total: 3.5
    Your program should validate the structure of the input files and display an appropriate error message if any issues are found. For example, if people.txt is empty, it should print a message such as: 'The people.txt file is empty.' Similarly, if a line is missing an item, or if the payment is not a valid integer or floating-point number, the program should generate an error message. For instance, if payments . txt contains a line like this:
    Alice 2.5
    Or if we have something like this:
    Alice pen two
    It should generate an appropriate error message. We assume there are no empty lines between the data, all people's names start with a capital letter, and all other letters (for both names and objects) are lowercase. Additionally, we assume that a single space separates names and payments. Finally, the numbers in payments . txt are assumed to have at most two digits after the decimal point. Therefore, you do not need to validate these aspects.
    Please follow this format precisely, with no additional output, as I will be running your programs through automated tests. The tests will use my own files payments.txt and people.txt with the same format as the above examples, but may involve different data.
    Your solution should make appropriate use of at least one class and at least one container.
    Coursework
    There is a single coursework in this module, counting for 30% of the overall module mark.
    This coursework is due at 5 pm on Sunday 1st  December. As with all modules, this deadline is
    hard. (See "Submission" below for the procedure for applying for extensions.)
    This coursework simulates a simple database operation, and provides practice with classes
    and standard containers. It does not require any features covered after session 6.
    Description
    The file payments.txt contains a simple textual table. Each line lists three pieces of
    information: a person's name, an object name, and the price of the object purchased by the person,
    separated by one space, e.g.:
    Bob eggs 2.5
    Alice apple 1.5
    Ava pen 2
    Bob pen 3.5
    Alice eggs 2
    (The meaning of the units depends on the objects, and need not concern us.) You may assume that
    person and object names do not contain spaces. The records are not in any special order. You may
    assume that any combination of person and object (e.g. Bob eggs) occurs at most once.
    To read this file, you will need to use the class ifstream, which is derived from istream,
    like so:
    #include it to the standard output. For each statement, the first line should display the person's name. The
    following lines should list the objects they purchased along with the amount paid for each object
    (one object per line). Finally, the last line should print "Total: value", where value is the
    sum of all payments. For example, for the given inputs (payments.txt and people.txt),
    it should print:
    Bob
    eggs 2.5
    pen 3.5
    Total: 6
    Alice
    apple 1.5
    eggs 2
    Total: 3.5
    Your program should validate the structure of the input files and display an appropriate error
    message if any issues are found. For example, if people.txt is empty, it should print a
    message such as: 'The people.txt file is empty.' Similarly, if a line is missing an
    item, or if the payment is not a valid integer or floating-point number, the program should
    generate an error message. For instance, if payments . txt contains a line like this:
    Alice 2.5
    Or if we have something like this:
    Alice pen two
    It should generate an appropriate error message. We assume there are no empty lines between
    the data, all people's names start with a capital letter, and all other letters (for both names and
    objects) are lowercase. Additionally, we assume that a single space separates names and
    payments. Finally, the numbers in payments . txt are assumed to have at most two digits after
    the decimal point. Therefore, you do not need to validate these aspects.
    Please follow this format precisely, with no additional output, as I will be running your pro-
    grams through automated tests. The tests will use my own files payments.txt and
    people.txt with the same format as the above examples, but may involve different data.
    Your solution should make appropriate use of at least one class and at least one container.
    can you please provde an exact code solution and detailed steps with expleantions
    student submitted image, transcription available
  • Chegg Logo
    There are 3 steps to solve this one.
    Solution
    Step 1

    Overview:

    Coursework requirs to write a C++ you program that reads two files, payments.txt and people...

    View the full answer
    answer image blur
    Step 2
    Unlock
    Step 3
    Unlock
    Answer
    Unlock