Learning Goal: I’m working on a programming project and need the explanation and answer to help me learn.
Write a program that allows the user to manage the sales amounts of the current year.
Product Sales Management System
show – Display all sales records
view – View an amount of a specified month
max – View the highest sales amount
min – View the lowest sales amount
edit – Edit an amount of a specified month
total – Get the total of all sales
quit – Terminate the program
Invalid command. Try again
Three-character month: jun
The sales amount: $4324
The highest sales amount: $15578
The lowest sales amount: $88
Three-character month: Jun
New amount updated
Thank you for using my app.
- The project should contain three files: main.h, main.cpp, and functions.asm
- main.h contains the following items:
- C/C++ libraries – Imports necessary library functions
- constant definitions – Defines constants for arrays:
- #define MONTH_SIZE 4 //Max number of characters for the month: 3 letters and ”
- #define LINE_SIZE 20 //Max number of characters for each line of the text file
- #define COMMAND_SIZE 10 //Max number of characters for each user command
- struct definition – Defines a structure named salesRecords that contains the month and the sales amount members
- function prototypes – Defines function prototypes used in man.cpp and functions.asm
- main.cpp contains the following functions:
- main() – Starts the project
- print_title() – Prints the title of this application
- print_menu() – Prints the command menu
- read_file() – Reads a text file
- write_file() – Writes a new sales amount for a specified month back to the file
- get_amount() – Receives the new sales amount from the user
- functions.asm contains the following procedures:
- show – Displays all data of the year
- max – Returns the highest sales amount
- min – Returns the lowest sales amount
- view – Prints a sales amount for a specified month
- edit – Modifies a sales amount for a specified month
- total – Returns the sales total for the year
- functions.asm also contains the following items:
- MONTH_SIZE = 4 ;Max number of characters for the month: 3 letters and ”
- MONTHS = 12 ;Max number of months of the year
- salesRecords STRUCT
- Functions prototypes defined in main.cpp: get_amount() and write_file()
- Data labels and messages
- The main function should define a structure for one month data, an array of characters for a command, and an array of 12 structures for all sales.
- All the commands should be entered in the main function and the program calls corresponding assembly language procedures.
- Use C/C++ code to read the text file and store the sales data in the array of structures. Each line is stored in a structure which has the following members:
- char month[MONTH_SIZE];
- int amount;
- MONTH_SIZE is a constant which is defined as 4.
- If the sales data of any month is edited, the program should write the entire updated array of structures back to the text file.
- Use the integer format for sales amounts.
- Assume the user enters valid inputs, so you are not required to check data type exceptions.
All files must be ran together and not separately. Please write the code in x86 assembly language with Irvine 32.inc and also using Visual Studio 2022 and not VS Code. Also provide the output similar to the example from the Visual Studio Debugger after code is complete.
(Provided a main.h and main.cpp that does allow for the user to change the sales amount for a specified month but not too sure if it implements the other commands but just wanted to provide a reference.)