Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Part 1 ( 0 % ) This workshop consists of two modules: w 1 ( partially supplied ) Food Order w 1 Module ( partially
Part
This workshop consists of two modules:
wpartially supplied
Food Order
w Module partially supplied
Study the code supplied and make sure you understand it
Finish the implementation of the main function, by completing the parts marked with TODO:
write the prototype of the main function to receive a set of standard command line arguments
echo the set of arguments to standard output in the following format:
: first argument
: second argument
: third argument
:
Do not modify this module in any other place!
FoodOrder Module
The FoodOrder module defines the current tax rate and daily special discount, as two global variables named gtaxrate and gdailydiscount that stores double values. The value of the tax rate and daily discount may change from day to day. These two variables will be accessed when a new day of orders starts from the main function.
This module also defines a class named FoodOrder in the namespace seneca that stores some information about an order of food:
a Cstyle nullterminated string of up to characters including the null byte terminator representing the name of the customer ordering the food.
a Cstyle nullterminated string of up to characters including the null byte terminator representing the description of the food.
the price of the food represented by a double value.
a boolean flag indicating whether or not the order is a daily special
Public Members
Default constructor
read: a modifier that receives an istream reference.
If the istream is in a good state, this function will attempt to read from the istream and store the information read into current object. The data read in will be in the following format:
newline
The daily special status can be of two values: Y for it is a special and N for it is not.
If the istream object is not in a good state then this function will do nothing.
When implementing the read function it may be advisable to review the InputOutput Objects chapter from the Course Notes.
display: a query that displays to the screen the content of an Food Order instance in the following format:
COUNTER. Name Order Description Price wTax Special Price
If no customer name has been stored in the current object, this query should print:
COUNTER. No Order
where
COUNTER is a left aligned field of size that holds the number of times that this function has been called use a localtofunction variable that remains in memory for the lifetime of the program Do not use globalmember variables to store the counter!
Name is a left aligned field of size that represents the name of the customer that made the order.
Order Description is a left aligned field of size that represents the description of the food ordered.
Price wTax is a left aligned field of size with decimal point precision that represents the price of the food ordered with tax calculated based on the current tax rate.
Special Price is a right aligned field of size that represents the taxed price of the food ordered with the daily discount applied on top if the order was a daily special. If the order isn't a daily special then nothing is printed here.
Add any other private members that your design requires without changing the specs above
Sample Output
The input files daytxt and daytxt are already provided; the main module contains a description of the structure for these files.
When the program is started with the command:
ws daytxt daytxt
the output should look like the one from the sampleoutput.txt file.
Test Your Code
To test and demonstrate execution of your program use the same data as shown in the output example above.
Upload your source code to your matrix account. Compile and run your code using the latest version of the g compiler available at usrlocalgccbing and make sure that everything works properly.
Then, run the following command from your account replace profname.proflastname with your professors Seneca userid:
~profname.proflastnamesubmit wp
and follow the instructions.
This part represents a milestone in completing the workshop and is not marked!
Part
For this part of the workshop, upgrade your FoodOrders class to accept an food description in the form of a Cstyle nullterminated string of any length. Make sure your program doesn't have memory leaks.
In order to facilitate the changes needed for this part, consider the use of these std::string related functions:
std::getline
std::string::cstr
std::string::length
Sample Output
When the program is started with the command:
ws daytxt missing.txt daytxt
the output should look like the one from the sampleoutput.txt file.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started