Write a script for the problem.
정보
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
이전 댓글 표시
(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.”
댓글 수: 0
답변 (1개)
Chad Greene
2015년 10월 29일
0 개 추천
댓글 수: 0
이 질문은 마감되었습니다.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!