Question
1. For Special Event Bookings, A Buffet Restaurant Charges A Fixed Price Of $21.59 Per Person But Offers A Discount For Large Groups. The Amount
1. For Special Event Bookings, A Buffet Restaurant Charges A Fixed Price Of $21.59 Per Person But Offers A Discount For Large Groups. The Amount Of The Discount Depends On The Size Of The Group. Develop An Algorithm And Write The C Code For A Program That Will Compute The Total Bill Including The Discount Based On The Number Of People In Indicated At The
Q62;
For this exercise you must write a program which generates a set of random numbers from three ranges and stores them in a binary file using system calls.
The program should meet the following criteria:
- The program should be named createFile
- The program should be able to be called in one of three ways:
- createFile
- createFile
- createFile
The command line arguments represent the following:
- - name of the binary file, if the value isn't specified default it to flowData.dat
- - total number of values to generate, if this value isn't specified default it to 60
- - the average value of the lower range, if this value isn't specified default it to 5
- - the average value of the middle range, if this value isn't specified default it to 10
- - the average value of the upper range, if this value isn't specified default it to 15
The createFile program will follow a simple process:
- loop while all the numbers haven't been written to the file
- generate a random number between 0 and 100 to determine which range to use
- generate a random number between -.5 and .5 to create the offset
- create the value to be stored by
- adding the offset to the chosen range's average
- multiplying the resulting number by 100
- truncating the number to an integer
- use a union to convert the newly created integer to a 4 byte character buffer
- output the bytes 0 and 1 of the character buffer. we aren't outputting bytes 2 and 3 of the character buffer because they are always 0.
The odds of each range being written into the file of random numbers are fixed.
The lower range is written into the file if a random number between 0 and 15 is generated;
the upper range is written into the file if a random number between 85 and 100 is generated;
all other values should be in the middle range.
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