This preview shows page 1. Sign up to view the full content.
Unformatted text preview: Solution: %quiz4.m clear N = input(Enter the number of balls in the sequence: ); num_R = 0; num_B = 0; num_Y = 0; k = 0; while k < N k = k+1; color = input(Enter the color of ball: ,s); % switch(color) % case R % num_R = num_R + 1; % case B % num_B = num_B + 1; % case Y % num_Y = num_Y + 1; % end if color == R num_R = num_R + 1; elseif color == B num_B = num_B + 1; else num_Y = num_Y + 1; end end fprintf(\n Number of Red = %g \t Number of Blue = %g \t Number of Yellow = %g \n, . .. num_R,num_B,num_Y)...
View Full
Document
 Spring '07
 Hayes

Click to edit the document details