Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:

  1. The program should be named createFile
  2. The program should be able to be called in one of three ways:
    1. createFile
    2. createFile
    3. 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:

  1. loop while all the numbers haven't been written to the file
    1. generate a random number between 0 and 100 to determine which range to use
    2. generate a random number between -.5 and .5 to create the offset
    3. create the value to be stored by
      1. adding the offset to the chosen range's average
      2. multiplying the resulting number by 100
      3. truncating the number to an integer
    4. use a union to convert the newly created integer to a 4 byte character buffer
    5. 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

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

Combinatorial Testing In Cloud Computing

Authors: Wei-Tek Tsai ,Guanqiu Qi

1st Edition

9811044805, 978-9811044809

More Books

Students also viewed these Programming questions