Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The Problem Statement Your friend is starting a new business. She's gotten access to discounts all over town from stores, restaurants, and more. She's been

The Problem Statement

Your friend is starting a new business. She's gotten access to discounts all over town from stores, restaurants, and more. She's been selling her discounts to students but is having trouble keeping tabs on who owes her money. She's offered you a 20% cut of her total revenue to build a program that will track each student she sells to, the sale price of each item, and the amount of money she's collected from that person.

Scaffolds

You will be provided with a program scaffold to complete for this assignment. Scaffolds, also called skeleton code, are programs that already have some of the solution completed. Do not modify the code that is already present. Instead, fill in the sections that are maked like this: /*** ... ***/

Download the scaffold here: accounts_scaffold.cimage text in transcribedimage text in transcribed

Program Description

Your program will read information from an input from a file that stores information about every transaction you friend makes. You may assume that your roommate has no more than 100 customers and each customer is labeled 0 through 99. An array has already been created to store information about these customers.

Your program will need to respond to three different commands:

Add a payment

Sell an item

Print messages for negative accounts

For commands of types 1 and 2, your program should update the appropriate customer account. A command of type one adds value to the account and a command of type two subtracts value from an account.

For commands of type 3, you should print out a message with the following format for each customer (in order of customer number) that has a negative account balance:

Customer X, you owe $Y. Please pay immediately!

where X is the account number and Y is the number of dollars owed (a positive amount).

If all accounts are paid properly, then print out the single line:

All accounts are paid up to date!!!

These commands will come from an input file.

Input File Format

The first line of the input file contains a single positive integer, n (n 1000), representing the number of commands to process. The commands follow, one per line.

Each command line will start with an integer, 1, 2 or 3, corresponding to the types of commands listed above. For command types 1 and 2, this will be followed with a space and a second integer, ID (0 ID 99), representing the identification number of the customer for the transaction. This will be followed by another space and a positive integer, v (v 100), representing the amount of dollars for the transaction. Commands of type 3 will have no further information following them.

Sample Run

There are three examples of what your program should look like when its finished. There are three input files and the output is shown in the corresponding output file. However, you do not need to create an output file in your program.

Input Files

account1.txtimage text in transcribedimage text in transcribed

account2.txtimage text in transcribedimage text in transcribed

account3.txtimage text in transcribedimage text in transcribed

Corresponding Output

account1.outimage text in transcribed

11

2 0 10

2 1 20

2 2 30

3

1 0 12

1 2 15

3

1 2 15

3

1 1 20

3

account2.outimage text in transcribed

18

2 0 10

2 1 40

2 3 30

2 3 40

2 3 50

2 1 10

2 3 40

1 0 10

1 2 20

1 3 100

3

2 3 30

2 2 15

1 1 50

3

2 2 10

1 3 90

3

.out and .txt are unformatted files that can be opened with most text editors. Code::Blocks can also create and read files of these types.

Specification

Homework assignments are either correct or incorrect. Do not modify any of the printf statements in the scaffold. Do not add any printf statements to the program.

Submission

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Systems

Authors: Ramez Elmasri, Shamkant B. Navathe

7th Edition Global Edition

1292097612, 978-1292097619

More Books

Students also viewed these Databases questions