Write a script for the problem.
Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
Ältere Kommentare anzeigen
(a) A machine cuts N pieces of a pipe. After each cut, each piece of pipe is weighed and its length is measured; these 2 values are then stored in a file called pipe.dat (first the weight and then the length on each line of the file). Ignoring units, the weight is supposed to be between 2.1 and 2.3, inclusive, and the length is supposed to be between 10.3 and 10.4, inclusive. The following is just the beginning of what will be a long script to work with these data. For now, the script will just count how many rejects there are. A reject is any piece of pipe that has an invalid weight and/or length. For a simple example ‐if N is 3 (meaning three lines in the file) and the file stores: 2.14 10.30 2.32 10.36 2.20 10.35 there is only one reject, the second one, as it weighs too much. The script would print: There were 1 rejects.
(b) Improve the output from the previous problem. If there is only 1 reject, it should print “There was 1 reject.”; otherwise for n rejects it should print “There were n rejects.”
Antworten (1)
Chad Greene
am 29 Okt. 2015
0 Stimmen
Diese Frage ist geschlossen.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!