hw3q2 - elseif (ScrewNumber); odds=odds+1; %fprintf('Place...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
num6 = 0; num8 = 0; num10 = 0; num12 = 0; odds = 0; fprintf('Input screw size\n'); response = 'Y'; r while response=='Y'; w ScrewNumber = input(''); if (ScrewNumber == 6); num6 = num6+1; %fprintf('Place in Cup One, Number of Screws in Cup One %0.0f \n', num6); elseif (ScrewNumber == 8); num8 = num8+1; %fprintf('Place in Cup Two, Number of Screws in Cup Two %0.0f \n', num8); elseif (ScrewNumber ==10); num10 = num10+1; %fprintf('Place in Cup Three, Number of Screws in Cup Three %0.0f \n', num10); elseif (ScrewNumber ==12); num12 = num12+1; %fprintf('Place in Cup Four, Number of Screws in Cup Four %0.0f \n', num12);
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: elseif (ScrewNumber); odds=odds+1; %fprintf('Place in Odds Cup, Number of Screws in Odds Cup %0.0f \n', odds); end response = input('Do you wish to enter another screw size? Y or N?\n', 's'); end e fprintf('Machine Screw Sorting and Counting Algorithm\n'); fprintf(' #6 #8 #10 #12 Odd \n'); fprintf('%5.0f %5.0f %5.0f %5.0f %5.0f \n', num6, num8, num10, num12, odds); fprintf('The number of machine screws correctly sorted is %0.0f\n', (num6+num8+num10+num12)); fprintf('The total number of machine screws sorted is %0.0f\n', (num6+num8+num10+num12+odds));...
View Full Document

This note was uploaded on 09/19/2011 for the course ENGE 1114 taught by Professor Twknott during the Fall '06 term at Virginia Tech.

Ask a homework question - tutors are online