vec = [0:.5:10]; cont = 1;store = 0;while( cont ==1) try score = input('Please enter a test score: '); disp(score == .5000) if(find(vec,score)) disp(score) end catch disp('Please enter scores in increments of .5') end cont = input('Please enter 1 to continue: ');end
This is the code I am currently working with. I am trying build a test averaging program for a professor and he assured me that all test scores would be in increments of .5 ; I am using the find function to confirm that they are increments of .5 and that the test scores are within the valid range. For some reason I can only get true within my if statement when I have score of increments of 1 and not .5 ; does anyone have a solution to this or an explanation? Thanks in advance!
Best Answer