讲解CMPT128 D100、辅导C/C++语言、辅导Computing Science、C/C++程序设计讲解

- 首页 >> C/C++编程

2018/11/12 Assignment #1: CMPT128 D100 Introduction to Computing Science and Programming for Engineers

https://canvas.sfu.ca/courses/40895/pages/assignment-number-1 1/32

Assignment #1

Assignment summary

In this assignment you need to write and submit a C++ program to model one aspect of a Coin

Sorter (details below).

Feel free to use any helper functions that you might find useful for the implementation of your

program (e.g. using get() function to read a char from the input/file

stream; using peek() function to remove any tabs or spaces; and noting the ASCII codes of

different characters (https://en.wikipedia.org/wiki/ASCII) ).

Important notes

This is an individual assignment:

You must complete this assignment individually, you MAY NOT work in groups

Any kind of cheating will lead to zero and SFU dishonesty policy will be strictly enforced.

You will need to develop an algorithm for the code you submit as part of the development of your

code. But, do not submit the algorithm for grading

You need to submit code and the code should be in a file with filename CoinSorterControl.cpp

Your code must be properly commented

Your code must adhere to the course Coding Standards

(https://canvas.sfu.ca/courses/40895/pages/coding-standards)

This file needs to be submitted to Canvas (the course management system)

The code you submit for this assignment will be tested against a grading test plan; therefore,

students encourage to use diffMerege to test their outputs.

If your code does not compile and produce results, the MAXIMUM grade you can receive is 22.5%

of the total mark of the assignment.

You will be given sample input and output files that test many of the conditions tested in the

grading test plan. These sample test files provided DO NOT test ALL conditions tested in the grading

test plan.

Download all input/output files on your computer for testing your code, browser view of these files

may not show the intended content.

Assignment 1 submission: Assignments -> Assignment-1 Code Submission

Problem details

You need to write part of the software to control a Coin Sorter machine. To prepare for this you will write

a simulator to model the Coin Sorter machine.

The Coin Sorter machine you are modelling will eventually work in a bank where large quantities of coins

are sorted and placed into rolls. This bank receives several kinds of coins. The Coin Sorter machine

2018/11/12 Assignment #1: CMPT128 D100 Introduction to Computing Science and Programming for Engineers

https://canvas.sfu.ca/courses/40895/pages/assignment-number-1 2/32

separates up to five kinds of coins from a bag of assorted coins. It separates coins based on diameter,

weight, and image. When configured for Canadian coins the weights and diameters are listed in the

following table.

Coin Weight Diameter Coins per roll

Nickel 3.95g ± 0.35g 21.0mm ± 0.8mm 40

Dime 1.75g ± 0.45g 18.0mm ± 0.7mm 50

Quarter 4.40g ± 0.40g 23.7mm ± 0.9mm 40

Loonie 7.00g ± 0.50g 26.0mm ± 1.0mm 25

Twonie 7.30g ± 0.55g 28.0mm ± 1.1mm 25

The unsorted coins are placed in a bin at the top of the Coin Sorter. The bin is shaken so that one coin at

a time enters the machine through a large slot. When a coin enters the slot it slides/rolls into a measuring

enclosure. Once the coin is in the measuring enclosure the Coin Sorter then:

I. measures the diameter of the coin

II. measures the weight of the coin

III. determines if the coin is bent

IV. compares an image of each face of the coin to each image in a bank of images showing the

expected images for each face of the coin (nickel, dime, etc.)

The Coin Sorter sorts coins into the following types: bent coins, nickels, dimes, quarters, loonies, toonies,

and all other coins.

The following steps are used to identify the type of a given coin:

1. The sorter will determine if the coin is bent:

a. If the coin is bent it is placed into the bent coin container

2. The bent coin container can hold up to 100g of bent coins.

3. If the coin is not bent the Coin Sorter will measure the diameter and weight of the coin:

a. If the coin (a coin that is not bent) does not fall into any of the possible weight ranges it is placed

in the other coins container.

b. If the coin (a coin that is not bent) does not fall into any of the possible diameter ranges it is place

in the other coins container

c. If the coin (a coin that is not bent) does not have the correct weight AND the correct diameter to

be a Canadian nickel, dime, quarter, loonie or toonie it is placed in the other coins container

4. The other coins container can hold up to 200g of other coins

5. If the coin (a coin that is not bent) has BOTH the correct weight and the correct diameter to be a

Canadian nickel, dime, quarter, loonie or toonie then an image (photo) of each side of the coin is taken.

Refer to the two sides of the coin as the front side of the coin and the back side of the coin.

a. If the image of the front side of the coin matches one of the reference images of the front side of

Canadian nickels, AND the image on the back side of the coin matches one of the reference images of

2018/11/12 Assignment #1: CMPT128 D100 Introduction to Computing Science and Programming for Engineers

https://canvas.sfu.ca/courses/40895/pages/assignment-number-1 3/32

the back side of Canadian nickels the coin is idenfied

as a Canadian nickel.

b. If the image of the front side of the coin matches one of the reference images of the front side of

Canadian dimes, AND the image on the back side of the coin matches one of the reference images of

the back side of Canadian dimes the coin is idenfied

as a Canadian dime

c. If the image of the front side of the coin matches one of the reference images of the front side of

Canadian quarters, AND the image on the back side of the coin matches one of the reference images

of the back side of Canadian quarters the coin is identified as a Canadian quarter

d. If the image of the front side of the coin matches one of the reference images of the front side of

Canadian loonies, AND the image on the back side of the coin matches one of the reference images

of the back side of Canadian loonies the coin is identified as a Canadian loonie

e. If the image of the front side of the coin matches one of the reference images of the front side of

Canadian toonies, AND the image on the back side of the coin matches one of the reference images of

the back side of Canadian toonies the coin is idenfied

as a Canadian toonie

6. If the coin has been idenfied

as a Canadian nickel it is placed into a coin wrapper for a roll of nickels

a. The number of nickels placed in the wrapper must be counted.

b. Nickels are placed into the wrapper until it is full (contains 40 Canadian nickels)

7. If the coin has been idenfied

as a Canadian dime it is placed into a coin wrapper for a roll of dimes

a. The number of dimes placed in the wrapper must be counted

b. Dimes are placed into the wrapper until it is full (contains 50 Canadian dimes)

8. If the coin has been idenfied

as be a Canadian quarter it is placed into a coin wrapper for a roll of

quarters

a. The number of quarters placed in the wrapper must be counted

b. Quarters are placed into the wrapper until it is full (contains 40 Canadian quarters)

9. If the coin has been idenfied

as a Canadian loonie it is placed into a coin wrapper for a roll of loonies

a. The number of loonies placed in the wrapper must be counted

b. Loonies are placed into the wrapper until it is full (contains 25 Canadian loonies)

10. If the coin has been idenfied

as a Canadian toonie it is placed into a coin wrapper for a roll of toonies

a. The number of toonies placed in the wrapper must be counted

b. Toonies are placed into the wrapper until it is full (contains 25 Canadian toonies)

11. If a coin wrapper or coin container becomes full, then the sorter pauses (does not sort more coins)

unl

the full wrapper is removed and a new empty wrapper is inserted. This process is mechanized

and takes 10 seconds to complete.

The Coin Sorter you are simulating examines a coin in the measuring enclosure. As it examines the coin,

the Coin Sorter uses two sensors. The first sensor is used to make a measurement that can be used to

determine the weight of the coin. The second sensor is used to make a measurement that can be used

to determine the diameter of the coin. Each of these sensors produces an integer value between 0 and

255. You will read the integer values that would be produced by the sensors from your input file. Details

of the methods used to determine the height and the diameter from the sensor measurements are

explained below.

The Coin Sorter uses a mechanical method to determine if the coin is bent. The result from this

mechanical measurement is a string with a value of “bent” or “usable”. Your program will also read this

string from the input file.

The Coin Sorter uses image processing to determine if the coin is a slug. A slug is a disc of metal of the

same size and weight as the coin but is not a real coin. The result from the image processing gives a

2018/11/12 Assignment #1: CMPT128 D100 Introduction to Computing Science and Programming for Engineers

https://canvas.sfu.ca/courses/40895/pages/assignment-number-1 4/32

value “BothMatch”, “OneMatch” or “NoMATCH”. Your program will also read the strings that would be

produced by the image processing from your input file.

Your simulation of the Coin Sorter will be required to incorporate the following functionality:

1. Prompt for and read the filename of the file containing the input data. The file should be in the

correct directory within your project. You should use the prompt below (Note that this prompt ends with

one space)

MAKE THE SIZE OF THE CHARACTER ARRAY OR STRING HOLDING YOUR FILENAME >=1024

we need to use long file names when grading your code.

Type the name of the input file containing sensor readings:

2. Open the input file containing the sensor readings

3. Check the input file is open. If the file has not been opened correctly, print the following message

then go back to step 1 and re-prompt for the file name. Re-prompt a maximum of 2 mes.

(prompt a

maximum of 3 mes)

ERROR: File FILENAME could not be opened for input

NOTE: in this message FILENAME will be replaced with the input filename provided by the user

If all 3 tries fail print the message

ERROR: You exceeded maximum number of tries allowed

while entering the input file name

and terminate the program

4. Prompt for and read the filename of the output file. The output file should be created in your project

directory. You should use the prompt below (Note that this prompt ends with one space),

Type the name of the output file which will hold the simulaon

results:

5. Open an output file to save the results of your simulaon

6. Check the file is open. If the file has not been opened print the following message then go to step 4.

Repeat step 4 a maximum of two addional

mes.

ERROR: File FILENAME could not be opened for output

2018/11/12 Assignment #1: CMPT128 D100 Introduction to Computing Science and Programming for Engineers

https://canvas.sfu.ca/courses/40895/pages/assignment-number-1 5/32

NOTE: in this message FILENAME will be replaced with the output filename provided by the user.

If all 3 tries fail print the message

ERROR: You exceeded maximum number of tries allowed

while entering the output file name

and terminate the program

7. Read the number of lines of data in the input file (the first integer in the file, alone on the first line of

the file). 1 <= number of lines of data <= 5000

8. The result of reading the number of sensor readings must be checked.

a) If the file is empty (no number of lines of data is present in the file, no data or blank lines are in the

file), print the following message then close your open files then terminate your program

ERROR: Input data file is empty

b) If the first character cannot be part of an integer print the following message then close your open

files then terminate your program

ERROR: First piece of data in the file is not an integer

c) If the number of sensor readings in out of range (<=0 or > 5000) print the following message then

close your open files then terminate your program

ERROR: The number of sensor readings is out of range

Each remaining lines in the input file should include a pair of integers represenng

the two sensor

readings (weight and diameter) and two strings ( “bent” or “usable”) indicang

if the coin is bent and

(“BothMatch” or “OneMatch” or “NoMatch”) indicang

if the images of both faces, one face, or no faces of

the coin matched one of the library of possible images. In the input file each line of data is followed by a

blank line. The blank lines are not counted in the number of lines of data.

2018/11/12 Assignment #1: CMPT128 D100 Introduction to Computing Science and Programming for Engineers

https://canvas.sfu.ca/courses/40895/pages/assignment-number-1 6/32

REPEAT THE FOLLOWING BLOCK OF ACTIONS “NUMBER OF LINES” TIMES

9. Read one line of data from the input file. The first integer read will be the reading from the weight

sensor, the second integer read will the reading from the diameter sensor, the third value read (a string)

should be “usable” or “bent”, the fourth value read (a string) should be “BothMatch” , “OneMatch” or

“NoMatch”. These four inputs should be on the same line of the input file and should be separated by

spaces or tabs. In the data file there will be a blank line following each line of data.

10. In the data file Line 0 contains the number of lines of data (first line containing a number in the file),

line 1 is the first line containing two sensor measurements and two strings. Line N is the N line

containing two sensor measurements and two strings. Blank lines are not counted. It is possible that the

data file contains more lines of data or less lines of data than is indicated by the number of lines given as

the first value in the file.

11. Each me

a line of data is read it must be checked for each of the following possible problems. In all

cases listed below, NNN, should be replaced with the number of the line containing the problem pointed

out in the message. Only one message should be printed for a given line of data even if the line contains

more than one error. If two errors occur in the same line print the message for the error that is earliest in

the list below.

a) If weight sensor data read was not an integer (did not begin with a digit) print the message

ERROR: Weight sensor value read on line NNN is not an integer

Simulation terminated early: Please correct your data file

Then ignore the remainder of the data, and leave the repeated block

b) If the data was not read because there was no more data in the file (the last line of data was read by

the previous read OR there are no lines of data, just a number of lines) print the message

ERROR: No more data

Simulation completed early before line NNN of input

th

2018/11/12 Assignment #1: CMPT128 D100 Introduction to Computing Science and Programming for Engineers

https://canvas.sfu.ca/courses/40895/pages/assignment-number-1 7/32

Then leave the repeated block.

c) If only one sensor reading was present on the present line of data (present line can be any line of data

including the last line)

ERROR: Weight sensor measurement only

Ignoring line NNN of the input file

Then ignore the present line and move on to the next line

d) If diameter sensor data read was not an integer (did not begin with a digit) print the message

ERROR: Diameter sensor value read on line NNN is not an integer

Simulation terminated early: Please correct your data file

Then ignore the remainder of the data, and leave the repeated block

e) If only two sensor readings were present on the line of data (present line can be any line of data

including the last line)

ERROR: Weight and diameter sensor measurements only

Ignoring line NNN of the input file

Then ignore the present line and move on to the next line

f) If the string giving the result of the test to determine if the coin is bent is not “bent” or “usable” print

the following message

ERROR: Result of test to determine if coin is bent at line NNN is invalid

Ignoring this line of data

Then ignore the present line and move on to the next line

g) If only two sensor readings and one string were present on the line of data (present line can be any

line of data including the last line)

ERROR: Weight and diameter sensor measurements and bent string only

2018/11/12 Assignment #1: CMPT128 D100 Introduction to Computing Science and Programming for Engineers

https://canvas.sfu.ca/courses/40895/pages/assignment-number-1 8/32

Ignoring line NNN of the input file

Then ignore the present line and move on to the next line

h) If the value of the image processing result is not “BothMatch” or “OneMatch” or “NoMatch” print the

following message

ERROR: image processing result at line NNN is invalid

Ignoring this line of data

Then ignore the present line and move on to the next line

i) If there is extra data at the end of the line of data

ERROR: Extra data at line NNN. Ignoring extra data

j) If the data was not within the correct range of values 0<= sensor reading <=255, print the message

ERROR: Sensor reading out of range, ignoring line NNN in the input file

Where NNN is the line number of the out of range data (first line in the file is line 1). Then ignore the

data just read and move on the reading and analyzing the next pair of sensor readings.

12. If the data has been read with none of the problems above, or if there was extra data in the line, then

determine which kind of coin the row of data represents. To determine which kind of coin the row of data

represents.

a) If the value of the first string for this coin is “bent” then the coin is bent. No further calculaon

is

necessary.

b) If the coin is not “bent” then convert the integer between 0 and 255 to the weight of the coin in

grams. The sensor measures the increase in length of the spring in s spring balance. The length of the

spring varies from 2.00cm to 7.00cm inclusive, so the increase in length varies from 0.0 to 5.0 cm

inclusive. The weight of the coin will be between 0.00g and 10.00g inclusive. The length of the spring is

related to the weight of the coin or coin fragment by Hooke’s law and the relaon

can be simplified to give

2018/11/12 Assignment #1: CMPT128 D100 Introduction to Computing Science and Programming for Engineers

https://canvas.sfu.ca/courses/40895/pages/assignment-number-1 9/32

Weight in grams = 2* length increase of spring in cm

c) If the coin is not “bent” then convert the integer between 0 and 255 to the diameter of the coin.

Assume the diameter of a coin can be between 10mm and 40mm

d) Check to see if the weight and diameter of the coin are simultaneously consistent with the weight

and diameter of one of the Canadian coins listed above. If both weight and diameter are consistent you

have potenally

idenfied

the coin as one of the Canadian coins being sorted. Otherwise the type of the

coin is other.

e) For each coin that is potenally

idenfied

as one of the Canadian coins based on its weight and

diameter, use the image processing data to verify that the coin is in fact the that Canadian coin and not

some other coin. Once the identy

of the coin has been verified using the image processing data the coin

has been idenfied.

For each of the types of Canadian Coins, the idenfied

coin will be added to the wrapper (the roll) for that

type of coin.

For example if the coin is a dime the following steps will be taken

I. The number of dimes in the dimes wrapper will be checked

II. If the dimes wrapper is full it will be replaced and the number of dimes in the wrapper

will be reset to 0.

III. Otherwise the dime will be added to the roll of dimes by sending the dime to the

dimes wrapper.

IV. The number of dimes in the dimes wrapper will be incremented

The process is the same for each type of Canadian coin.

Your simulaon

will print messages that indicate when a coin is added to a coin wrapper and when a coin

wrapper is replaced. These messages are shown below in points 13-17 and 20-24.

2018/11/12 Assignment #1: CMPT128 D100 Introduction to Computing Science and Programming for Engineers

https://canvas.sfu.ca/courses/40895/pages/assignment-number-1 10/32

Bent coins and other coins are placed in containers, not in wrappers. The bent coin container holds up to

100g. The other coin container holds up to 200g. When you add a bent coin or an other coin to its

container

I. The weight of the coins in the container will be checked

II. If the new coin weighs too much to fit into the container, the container will be replaced

and the weight of coins in the new container will be updated to be the weight of the new coin.

III. Otherwise the new coin will be added to the container

IV. The weight of coins in the container will be updated.

Your simulaon

will print messages that indicate when a coin is added to a container and when a container

is replaced. These messages are shown below in points 18-19 and 25-26.

EITHER

13. When the coin is determined to be a nickel, and it is not the last nickel in a roll print the following

messages

The Coin Sorter has sent one coin to the nickels wrapper

There are now NN coins in the nickels wrapper

14. When the coin is determined to be a dime and it is not the last dime in a roll print the following

messages

The Coin Sorter has sent one coin to the dimes wrapper

There are now NN coins in the dimes wrapper

15. When the coin is determined to be a quarter and it is not the last quarter in a roll print the following

messages

The Coin Sorter has sent one coin to the quarters wrapper

There are now NN coins in the quarters wrapper

2018/11/12 Assignment #1: CMPT128 D100 Introduction to Computing Science and Programming for Engineers

https://canvas.sfu.ca/courses/40895/pages/assignment-number-1 11/32

16. When the coin is determined to be a loonie and it is not the last loonie in a roll print the following

messages.

The Coin Sorter has sent one coin to the loonie wrapper

There are now NN coins in the loonies wrapper


17. When the coin is determined to be a toonie and it is not the last toonie in a roll print the following

messages.

The Coin Sorter has sent one coin to the toonies wrapper

There are now NN coins in the toonies wrapper

18. When the coin is bent and adding the bent coin to the bent coin container does not make the bent

coin container overweight (print the following messages)

The Coin Sorter has sent this coin to the bent coin container

The coins in the bent coin container now weigh nnn.nn grams

19. When the coin is not one of the Canadian coins we are sorng

into wrappers (and is not bent) it will

be placed into the other coins container, unless adding the coin to the other coin container makes the

other coin container overweight

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh nnn.nn grams

OR

20. When the coin is determined to be a nickel, and it is the last nickel in a roll print the following

messages

The Coin Sorter has sent one coin to the nickels wrapper

2018/11/12 Assignment #1: CMPT128 D100 Introduction to Computing Science and Programming for Engineers

https://canvas.sfu.ca/courses/40895/pages/assignment-number-1 12/32

The nickel wrapper is now full

The nickel wrapper has now been replaced

21. When the coin is determined to be a dime and it is the last dime in a roll print the following messages

The Coin Sorter has sent one coin to the dimes wrapper

The dime wrapper is now full

The dime wrapper has now been replaced

22. When the coin is determined to be a quarter and it is the last quarter in a roll print the following

messages.

The Coin Sorter has sent one coin to the quarters wrapper

The quarter wrapper is now full

The quarter wrapper has now been replaced

23. When the coin is determined to be a loonie and it is the last loonie in a roll print the following

messages.

The Coin Sorter has sent one coin to the loonies wrapper

The loonie wrapper is now full

The loonie wrapper has now been replaced

24. When the coin is determined to be a toonie and it is the last toonie in a roll print the following

messages

The Coin Sorter has sent one coin to the toonies wrapper

The toonie wrapper is now full

The toonie wrapper has now been replaced

2018/11/12 Assignment #1: CMPT128 D100 Introduction to Computing Science and Programming for Engineers

https://canvas.sfu.ca/courses/40895/pages/assignment-number-1 13/32

25. When the coin is bent and adding the bent coin to the bent coin container would make the bent

container overweight (print the following messages).

The Coin Sorter has sent this coin to the bent coin container

This coin does not fit in the bent coin container

The bent coin container has been replaced

The coin in the new bent coin container weighs nnn.nn grams

26. When the coin is not one of the Canadian coins we are sorng

into wrappers (and is not bent) it will

be placed into the other coins container, unless adding the coin to the other coin container makes the

other coin container overweight

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh nnn.nn grams.

END OF REPEATED BLOCK

27. Summarize your simulation by printing the number of each kind of coin proces

sed and the weight of bent coins and other coins processed. Print these results wi

th the following formats. Skip three lines before printing the summary.

SUMMARY

The Coin Sorter made nnn rolls of nickels.

There are oo nickels in the partially full roll.

The Coin Sorter made ppp rolls of dimes.

There are xx dimes in the partially full roll.

The Coin Sorter made mmm rolls of quarters.

2018/11/12 Assignment #1: CMPT128 D100 Introduction to Computing Science and Programming for Engineers

https://canvas.sfu.ca/courses/40895/pages/assignment-number-1 14/32

There are yy quarters in the partially full roll.

The Coin Sorter made bbb rolls of loonies.

There are zz loonies in the partially full roll.

The Coin Sorter made ccc rolls of toonies.

There are ww toonies in the partially full roll.

The Coin Sorter processed qqqqq other coins.

The other coins completely filled sss containers

There were tt other coins in the partially full container

The total weight of the other coins was rrrrr.rrr grams

The Coin Sorter processed aaaaaa.aaaa g of bent coins

END OF TASK TO BE IMPLEMENTED AS A C++ PROGRAM

ALSO IMPORTANT

All prompts should be printed only to the screen

All output should be printed to cout and to the output file

All error messages should be printed only to cerr

TEST 1: Input file cannot be opened (no files xxx yyy or zzz in the project directory)

Console Output

Type the name of the input file containing sensor readings:

xxx

ERROR: File xxx could not be opened for input

Type the name of the input file containing sensor readings:

yyy

ERROR: File yyy could not be opened for input

Type the name of the input file containing sensor readings:

2018/11/12 Assignment #1: CMPT128 D100 Introduction to Computing Science and Programming for Engineers

https://canvas.sfu.ca/courses/40895/pages/assignment-number-1 15/32

zzz

ERROR: File zzz could not be opened for input

ERROR: You exceeded maximum number of tries allowed

while entering the input file name

TEST 2: Output file cannot be opened. Empty read only output file outputReadOnly.txt used as input

(provided with input files), (no files xxx yyy or zzz in the project directory)

Console Output


Type the name of the input file containing sensor readings:

inputTest2.txt

Type the name of the output file which will hold the simulation results:

outputReadOnly.txt

ERROR: File outputReadOnly.txt could not be opened

Type the name of the output file which will hold the simulation results:

outputReadOnly.txt

ERROR: File outputReadOnly.txt could not be opened

Type the name of the output file which will hold the simulation results:

outputReadOnly.txt

ERROR: File outputReadOnly.txt could not be opened

ERROR: You exceeded maximum number of tries allowed

while entering the output file name

TEST 3: input file empty, creates an empty output file

2018/11/12 Assignment #1: CMPT128 D100 Introduction to Computing Science and Programming for Engineers

https://canvas.sfu.ca/courses/40895/pages/assignment-number-1 16/32

Console output

Type the name of the input file containing sensor readings:

inputTest3.txt

Type the name of the output file which will hold the simulaon

results:

outputTest3.txt

ERROR: Input data file is empty

Test 4: First value in the input file begins with a character that is not a digit, creates an empty output file

Console output

Type the name of the input file containing sensor readings:

inputTest4.txt

Type the name of the output file which will hold the simulation results:

outputTest4.txt

ERROR: First piece of data in the file is not an integer


Test 5: Number of sensor readings too small, creates an empty output file

Console output

Type the name of the input file containing sensor readings:

inputTest5.txt

Type the name of the output file which will hold the simulation results:

outputTest5.txt

2018/11/12 Assignment #1: CMPT128 D100 Introduction to Computing Science and Programming for Engineers

https://canvas.sfu.ca/courses/40895/pages/assignment-number-1 17/32

ERROR: The number of sensor readings is out of range

Test 6: Number of sensor readings too large, creates an empty output file

Console output

Type the name of the input file containing sensor readings:

inputTest6.txt

Type the name of the output file which will hold the simulation results:

outputTest6.txt

ERROR: The number of sensor readings is out of range

Test7: No data on first line that should contain sensor readings and image proces

sing

result.

Console output

Type the name of the input file containing sensor readings:

inputTest7.txt

Type the name of the output file which will hold the simulation results:

outputTest7.txt

ERROR: No more data

Simulation completed early before line 1 of input

SUMMARY

The Coin Sorter made 0 rolls of nickels.

2018/11/12 Assignment #1: CMPT128 D100 Introduction to Computing Science and Programming for Engineers

https://canvas.sfu.ca/courses/40895/pages/assignment-number-1 18/32

There are 0 nickels in the partially full roll.

The Coin Sorter made 0 rolls of dimes.

There are 0 dimes in the partially full roll.

The Coin Sorter made 0 rolls of quarters.

There are 0 quarters in the partially full roll.

The Coin Sorter made 0 rolls of loonies.

There are 0 loonies in the partially full roll.

The Coin Sorter made 0 rolls of toonies.

There are 0 toonies in the partially full roll.

The Coin Sorter processed 0 other coins.

The other coins completely filled 0 containers

There were 0 other coins in the partially full container

The total weight of the other coins was 0.000 grams

The Coin Sorter processed 0.0000 g of bent coins

Output Fill

SUMMARY

The Coin Sorter made 0 rolls of nickels.

There are 0 nickels in the partially full roll.

The Coin Sorter made 0 rolls of dimes.

There are 0 dimes in the partially full roll.

The Coin Sorter made 0 rolls of quarters.

There are 0 quarters in the partially full roll.

The Coin Sorter made 0 rolls of loonies.

There are 0 loonies in the partially full roll.

2018/11/12 Assignment #1: CMPT128 D100 Introduction to Computing Science and Programming for Engineers

https://canvas.sfu.ca/courses/40895/pages/assignment-number-1 19/32

The Coin Sorter made 0 rolls of toonies.

There are 0 toonies in the partially full roll.

The Coin Sorter processed 0 other coins.

The other coins completely filled 0 containers

There were 0 other coins in the partially full container

The total weight of the other coins was 0.000 grams

The Coin Sorter processed 0.0000 g of bent coins

Test 8: Many Issues (not all) tested input file is posted

Type the name of the input file containing sensor readings:

in.txt

Type the name of the output file which will hold the simulation results:

out.txt

The Coin Sorter has sent one coin to the dimes wrapper

There are now 1 coins in the dimes wrapper

The Coin Sorter has sent one coin to the nickels wrapper

There are now 1 coins in the nickels wrapper

The Coin Sorter has sent one coin to the quarters wrapper

There are now 1 coins in the quarters wrapper

The Coin Sorter has sent one coin to the loonies wrapper

There are now 1 coins in the loonies wrapper

The Coin Sorter has sent one coin to the loonies wrapper

There are now 2 coins in the loonies wrapper

The Coin Sorter has sent one coin to the toonies wrapper

2018/11/12 Assignment #1: CMPT128 D100 Introduction to Computing Science and Programming for Engineers

https://canvas.sfu.ca/courses/40895/pages/assignment-number-1 20/32

There are now 1 coins in the toonies wrapper

The Coin Sorter has sent this coin to the bent coin container

The coins in the bent coin container now weigh 2.00 grams

The Coin Sorter has sent this coin to the bent coin container

The coins in the bent coin container now weigh 5.80 grams

The Coin Sorter has sent this coin to the bent coin container

The coins in the bent coin container now weigh 10.00 grams

The Coin Sorter has sent this coin to the bent coin container

The coins in the bent coin container now weigh 16.71 grams

The Coin Sorter has sent this coin to the bent coin container

The coins in the bent coin container now weigh 23.76 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 2.00 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 5.80 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 10.00 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 16.71 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 23.76 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 25.76 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 29.57 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 33.76 grams

2018/11/12 Assignment #1: CMPT128 D100 Introduction to Computing Science and Programming for Engineers

https://canvas.sfu.ca/courses/40895/pages/assignment-number-1 21/32

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 40.47 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 47.53 grams

ERROR: Weight sensor measurement only

Ignoring line 22 of the input file

ERROR: Weight and diameter sensor measurements only

Ignoring line 23 of the input file

ERROR: Weight and diameter sensor measurements and bent string only

Ignoring line 24 of the input file

ERROR: Extra data at line 25. Ignoring extra data

ERROR: Sensor reading out of range, ignoring line 25 in the input file

ERROR: Result of test to determine if coin is bent at line 26 is invalid

Ignoring this line of data

ERROR: image processing result at line 27 is invalid

Ignoring this line of data

ERROR: Sensor reading out of range, ignoring line 28 in the input file

ERROR: Sensor reading out of range, ignoring line 29 in the input file

ERROR: Sensor reading out of range, ignoring line 30 in the input file

ERROR: Sensor reading out of range, ignoring line 31 in the input file

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 48.63 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 51.22 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 56.86 grams

2018/11/12 Assignment #1: CMPT128 D100 Introduction to Computing Science and Programming for Engineers

https://canvas.sfu.ca/courses/40895/pages/assignment-number-1 22/32

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 65.69 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 67.84 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 72.08 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 76.78 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 84.24 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 91.92 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 101.92 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 111.92 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 121.92 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 130.75 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 140.75 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 141.61 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 144.63 grams

The Coin Sorter has sent this coin to the other coin container

2018/11/12 Assignment #1: CMPT128 D100 Introduction to Computing Science and Programming for Engineers

https://canvas.sfu.ca/courses/40895/pages/assignment-number-1 23/32

The coins in the other coin container now weigh 151.10 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 161.10 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 171.10 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 181.10 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 191.10 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 10.00 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 20.00 grams

The Coin Sorter has sent one coin to the toonies wrapper

There are now 2 coins in the toonies wrapper

The Coin Sorter has sent one coin to the toonies wrapper

There are now 3 coins in the toonies wrapper

The Coin Sorter has sent one coin to the toonies wrapper

There are now 4 coins in the toonies wrapper

The Coin Sorter has sent one coin to the toonies wrapper

There are now 5 coins in the toonies wrapper

The Coin Sorter has sent one coin to the toonies wrapper

There are now 6 coins in the toonies wrapper

The Coin Sorter has sent one coin to the toonies wrapper

There are now 7 coins in the toonies wrapper

The Coin Sorter has sent one coin to the toonies wrapper

2018/11/12 Assignment #1: CMPT128 D100 Introduction to Computing Science and Programming for Engineers

https://canvas.sfu.ca/courses/40895/pages/assignment-number-1 24/32

There are now 8 coins in the toonies wrapper

The Coin Sorter has sent one coin to the toonies wrapper

There are now 9 coins in the toonies wrapper

The Coin Sorter has sent one coin to the toonies wrapper

There are now 10 coins in the toonies wrapper

The Coin Sorter has sent one coin to the toonies wrapper

There are now 11 coins in the toonies wrapper

The Coin Sorter has sent one coin to the toonies wrapper

There are now 12 coins in the toonies wrapper

The Coin Sorter has sent one coin to the toonies wrapper

There are now 13 coins in the toonies wrapper

The Coin Sorter has sent one coin to the toonies wrapper

There are now 14 coins in the toonies wrapper

The Coin Sorter has sent one coin to the toonies wrapper

There are now 15 coins in the toonies wrapper

The Coin Sorter has sent one coin to the toonies wrapper

There are now 16 coins in the toonies wrapper

The Coin Sorter has sent one coin to the toonies wrapper

There are now 17 coins in the toonies wrapper

The Coin Sorter has sent one coin to the toonies wrapper

There are now 18 coins in the toonies wrapper

The Coin Sorter has sent one coin to the toonies wrapper

There are now 19 coins in the toonies wrapper

The Coin Sorter has sent one coin to the toonies wrapper

There are now 20 coins in the toonies wrapper

The Coin Sorter has sent one coin to the toonies wrapper

There are now 21 coins in the toonies wrapper

2018/11/12 Assignment #1: CMPT128 D100 Introduction to Computing Science and Programming for Engineers

https://canvas.sfu.ca/courses/40895/pages/assignment-number-1 25/32

The Coin Sorter has sent one coin to the toonies wrapper

There are now 22 coins in the toonies wrapper

The Coin Sorter has sent one coin to the toonies wrapper

There are now 23 coins in the toonies wrapper

The Coin Sorter has sent one coin to the toonies wrapper

There are now 24 coins in the toonies wrapper

The Coin Sorter has sent one coin to the toonies wrapper

The toonie wrapper is now full

The toonie wrapper has now been replaced

The Coin Sorter has sent one coin to the toonies wrapper

There are now 1 coins in the toonies wrapper

The Coin Sorter has sent one coin to the toonies wrapper

There are now 2 coins in the toonies wrapper

The Coin Sorter has sent one coin to the toonies wrapper

There are now 3 coins in the toonies wrapper

The Coin Sorter has sent one coin to the toonies wrapper

There are now 4 coins in the toonies wrapper

ERROR: No more data

Simulation completed early before line 83 of input

SUMMARY

The Coin Sorter made 0 rolls of nickels.

There are 1 nickels in the partially full roll.

The Coin Sorter made 0 rolls of dimes.

2018/11/12 Assignment #1: CMPT128 D100 Introduction to Computing Science and Programming for Engineers

https://canvas.sfu.ca/courses/40895/pages/assignment-number-1 26/32

There are 1 dimes in the partially full roll.

The Coin Sorter made 0 rolls of quarters.

There are 1 quarters in the partially full roll.

The Coin Sorter made 0 rolls of loonies.

There are 2 loonies in the partially full roll.

The Coin Sorter made 1 rolls of toonies.

There are 4 toonies in the partially full roll.

The Coin Sorter processed 33 other coins.

The other coins completely filled 1 containers

There were 2 other coins in the partially full container

The total weight of the other coins was 211.098 grams

The Coin Sorter processed 23.7647 g of bent coins


Output File

The Coin Sorter has sent one coin to the dimes wrapper

There are now 1 coins in the dimes wrapper

The Coin Sorter has sent one coin to the nickels wrapper

There are now 1 coins in the nickels wrapper

The Coin Sorter has sent one coin to the quarters wrapper

There are now 1 coins in the quarters wrapper

The Coin Sorter has sent one coin to the loonies wrapper

There are now 1 coins in the loonies wrapper

The Coin Sorter has sent one coin to the loonies wrapper

There are now 2 coins in the loonies wrapper

The Coin Sorter has sent one coin to the toonies wrapper

There are now 1 coins in the toonies wrapper

2018/11/12 Assignment #1: CMPT128 D100 Introduction to Computing Science and Programming for Engineers

https://canvas.sfu.ca/courses/40895/pages/assignment-number-1 27/32

The Coin Sorter has sent this coin to the bent coin container

The coins in the bent coin container now weigh 2.00 grams

The Coin Sorter has sent this coin to the bent coin container

The coins in the bent coin container now weigh 5.80 grams

The Coin Sorter has sent this coin to the bent coin container

The coins in the bent coin container now weigh 10.00 grams

The Coin Sorter has sent this coin to the bent coin container

The coins in the bent coin container now weigh 16.71 grams

The Coin Sorter has sent this coin to the bent coin container

The coins in the bent coin container now weigh 23.76 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 2.00 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 5.80 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 10.00 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 16.71 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 23.76 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 25.76 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 29.57 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 33.76 grams

2018/11/12 Assignment #1: CMPT128 D100 Introduction to Computing Science and Programming for Engineers

https://canvas.sfu.ca/courses/40895/pages/assignment-number-1 28/32

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 40.47 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 47.53 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 48.63 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 51.22 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 56.86 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 65.69 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 67.84 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 72.08 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 76.78 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 84.24 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 91.92 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 101.92 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 111.92 grams

The Coin Sorter has sent this coin to the other coin container

2018/11/12 Assignment #1: CMPT128 D100 Introduction to Computing Science and Programming for Engineers

https://canvas.sfu.ca/courses/40895/pages/assignment-number-1 29/32

The coins in the other coin container now weigh 121.92 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 130.75 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 140.75 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 141.61 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 144.63 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 151.10 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 161.10 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 171.10 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 181.10 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 191.10 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 10.00 grams

The Coin Sorter has sent this coin to the other coin container

The coins in the other coin container now weigh 20.00 grams

The Coin Sorter has sent one coin to the toonies wrapper

There are now 2 coins in the toonies wrapper

The Coin Sorter has sent one coin to the toonies wrapper

2018/11/12 Assignment #1: CMPT128 D100 Introduction to Computing Science and Programming for Engineers

https://canvas.sfu.ca/courses/40895/pages/assignment-number-1 30/32

There are now 3 coins in the toonies wrapper

The Coin Sorter has sent one coin to the toonies wrapper

There are now 4 coins in the toonies wrapper

The Coin Sorter has sent one coin to the toonies wrapper

There are now 5 coins in the toonies wrapper

The Coin Sorter has sent one coin to the toonies wrapper

There are now 6 coins in the toonies wrapper

The Coin Sorter has sent one coin to the toonies wrapper

There are now 7 coins in the toonies wrapper

The Coin Sorter has sent one coin to the toonies wrapper

There are now 8 coins in the toonies wrapper

The Coin Sorter has sent one coin to the toonies wrapper

There are now 9 coins in the toonies wrapper

The Coin Sorter has sent one coin to the toonies wrapper

There are now 10 coins in the toonies wrapper

The Coin Sorter has sent one coin to the toonies wrapper

There are now 11 coins in the toonies wrapper

The Coin Sorter has sent one coin to the toonies wrapper

There are now 12 coins in the toonies wrapper

The Coin Sorter has sent one coin to the toonies wrapper

There are now 13 coins in the toonies wrapper

The Coin Sorter has sent one coin to the toonies wrapper

There are now 14 coins in the toonies wrapper

The Coin Sorter has sent one coin to the toonies wrapper

There are now 15 coins in the toonies wrapper

The Coin Sorter has sent one coin to the toonies wrapper

There are now 16 coins in the toonies wrapper

2018/11/12 Assignment #1: CMPT128 D100 Introduction to Computing Science and Programming for Engineers

https://canvas.sfu.ca/courses/40895/pages/assignment-number-1 31/32

The Coin Sorter has sent one coin to the toonies wrapper

There are now 17 coins in the toonies wrapper

The Coin Sorter has sent one coin to the toonies wrapper

There are now 18 coins in the toonies wrapper

The Coin Sorter has sent one coin to the toonies wrapper

There are now 19 coins in the toonies wrapper

The Coin Sorter has sent one coin to the toonies wrapper

There are now 20 coins in the toonies wrapper

The Coin Sorter has sent one coin to the toonies wrapper

There are now 21 coins in the toonies wrapper

The Coin Sorter has sent one coin to the toonies wrapper

There are now 22 coins in the toonies wrapper

The Coin Sorter has sent one coin to the toonies wrapper

There are now 23 coins in the toonies wrapper

The Coin Sorter has sent one coin to the toonies wrapper

There are now 24 coins in the toonies wrapper

The Coin Sorter has sent one coin to the toonies wrapper

The toonie wrapper is now full

The toonie wrapper has now been replaced

The Coin Sorter has sent one coin to the toonies wrapper

There are now 1 coins in the toonies wrapper

The Coin Sorter has sent one coin to the toonies wrapper

There are now 2 coins in the toonies wrapper

The Coin Sorter has sent one coin to the toonies wrapper

There are now 3 coins in the toonies wrapper

The Coin Sorter has sent one coin to the toonies wrapper

2018/11/12 Assignment #1: CMPT128 D100 Introduction to Computing Science and Programming for Engineers

https://canvas.sfu.ca/courses/40895/pages/assignment-number-1 32/32

There are now 4 coins in the toonies wrapper

SUMMARY

The Coin Sorter made 0 rolls of nickels.

There are 1 nickels in the partially full roll.

The Coin Sorter made 0 rolls of dimes.

There are 1 dimes in the partially full roll.

The Coin Sorter made 0 rolls of quarters.

There are 1 quarters in the partially full roll.

The Coin Sorter made 0 rolls of loonies.

There are 2 loonies in the partially full roll.

The Coin Sorter made 1 rolls of toonies.

There are 4 toonies in the partially full roll.

The Coin Sorter processed 33 other coins.

The other coins completely filled 1 containers

There were 2 other coins in the partially full container

The total weight of the other coins was 211.098 grams

The Coin Sorter processed 23.7647 g of bent coins


Please be aware that the provided tests are not a complete set of tests. There are just enough tests to

show you the orders that some of the messages should occur in. It is your responsibility to assure your

program sasfies

ALL condions

in the descripon

of the problem regardless of whether those condions

are tested in the provided tests. It is your responsibility to assure your program works for any data set not

just those data sets given as sample tests.


站长地图