Submit your files on-line in CMS before the project deadline. See the CMS link on the course webpage for instructions on using CMS. Both correctness and good programming style contribute to your project score.
You must work either on your own or with one partner. You may discuss background issues and general solution strategies with others, but the project you submit must be the work of just you (and your partner). If you work with a partner, you and your partner must register as a group in CMS and submit your work as a group.
Read the following web pages to learn about ASCII (and also about writing your resume!). You don't have to read the entire documents--just the first page is sufficient. You may search the Internet for different articles on ASCII if you like.
Answer the questions by writing your responses after each question. Be neat! Keep line lengths to at most 70 characters. Again, be sure to save your work as a plain text file.
Download the program lineHunt.m and run it. A graphics window will pop up and the message near the top (the title area) says to click in the window. Each time you click, a circle will be drawn showing where you clicked; also, the title of the graphics window will change to show whether you hit or missed the hidden horizontal line (hint: the line is "hidden" at y = 4.5).
Read the program to make sure you understand what it does. Don't worry about the early commands to set up the figure window, but here's how the plot statement works: plot([x1 x2] [y1 y2]) draws a line from the point (x1,y1) to (x2,y2) while plot(x,y) draws a single point. The statement title('hello there') displays the text 'hello there' as the title of a figure.
Your job is to modify this program:
Find the course-grade cutoff values on the Syllabus page of the course website. Write a program to prompt for a score and then print out the corresponding course grade according to the cutoff value on the course website. Note that some scores correspond to more than one possible grade (e.g., 90 is either an A or a B). Some sample output for such a program appears below.
>> gradeSol
What is the score? 50
The grade is F
>> gradeSol
What is the score? 60
The grade is D
>> gradeSol
What is the score? 70
The grade is C
>> gradeSol
What is the score? 80
The grade is B
>> gradeSol
What is the score? 90
The grade is A or B
>> gradeSol
What is the score? 100
The grade is A
>> gradeSol
What is the score? 110
??? Error using ==> gradeSol
Score too large
You'll want to make use of built-in functions input, error and fprintf. Recall that information about any function can be found by typing "help funcName" at the Command Window prompt.
Use the input function to get a score. For example, the instruction x = input('Give me input. ') will print "Give me input." on the Command Window and will then wait for user input, storing the result in variable x.
If a bad score is given (i.e., greater than 100 or less than zero), your program should use the error function: error('This is an error message'). When the error function is executed, it will halt the program and print the error message on the Command Window. Your error message should be something meaningful that helps the user understand the causes of the error.
You've seen examples of the use of fprintf in lecture. fprintf('Hello! My name is %s.\n', name) will print the specified greeting, but with %s replaced by the string held in variable name. Recall that \n represents an end-of-line marker.