Docsity

5 Problems on Computing for Engineers with Solution - Exam 1 | CS 1371, Exams of Computer Science

Partial preview of the text

Download 5 Problems on Computing for Engineers with Solution - Exam 1 | CS 1371 and more Exams Computer Science in PDF only on Docsity!

CS 1371 Practice Test 1 Fall 2004 1. Basic Functions Write a Matlab function called weather that takes in a temperature (given in degrees Fahrenheit) and retums a character string with an appropriate simple message describing what the weather is like. Use the following table to determine which message to return for a given value of t (temperature): Temperature Weather t<32 Freezing 3285 Hot weather() takes in a temperature (degrees F) and returns a character string with an appropriate simple message describing what the weather is like ge a gp se function condition = Fweather (temp) %e weather help %o satay: weather” (temp) % —cetuens (subjectively) what the wealuer is {ike yen ts a temp in falurmleit degrees if temp >* 85 condition = Shot" 5 elgeif tem 20172 conslition = warm > elseif thew W Th Condition = ‘Rone Temp! 5 else sf temp > 60 condlition = ‘Chilly’ 5 elset temp 2 32 condition = Colol > else condition = freezing 5 en