Homework Help #1

ascendantofrain

Solid State Member
Messages
10
Hey guys, I am already going to be asking for a little help....I believe i have an okay idea of what I am doing but I would just like to make sure I am doing things right and if I am not, I would hope to hear constructive criticism.

Here's the problem:

If myAge and yourRate are numeric variables, and departmentCode is a character variable, which of the following statements are valid assignments? If a statement is not valid, explain why not.

a. myAge = 23 is a valid assignment
b. myAge = yourRate is a valid assignment
c. myAge = departmentCode is not a valid assignment because departmentCode is a character variable and character variables need quotes.
d. myAge = “departmentCode” is a valid assignment.
e. 42 = myAge is not a valid assignment because assignments must begin with alphabetic characters.
f. yourRate = 3.5 is a valid assignment.
g. yourRate = myAge is a valid assignment.
h. yourRate = deaprtmentCode is not a valid assignment because both values would have to be character values for it to be true or departmentCode must have quotes.
i. 6.91 = yourRate is not a valid assignment because assignments must begin with alphabetic characters.
j. departmentCode = Personnel is not a valid assignment because values for a character variable must be in quotes.
k. departmentCode = “Personnel” is a valid assignment.
l. departmentCode = 413 is not a valid assignment because character variables must equal a constant in quotes.
m. departmentCode = “413” is a valid assignment.
n. departmentCode = myAge is a valid assignment.
o. departmentCode = yourRate is a valid assignment
p. 413 = departmentCode is not a valid assignment because assignments must begin with alphabetic characters.
q. “413” = departmentCode is not a valid assignment because a assignments must begin with alphabetic characters.


Obviously my answers are written after the "assignment"....thanks for your help guys!!!
 
It is just basic Introduction to Programming Logic and Design....a class I am taking towards my major of Web Development.....I am also taking an Internet Tools (html), Web Site Administration, and Operating Systems (Linux) classes.
 
mostly correct, however,m some of the answers/reasons are wrong...


c. myAge = departmentCode is not a valid assignment because departmentCode is a character variable and character variables need quotes.

myAge = departmentCode is not valid because myage is numeric and department code is char, mismatched datatype.

d. myAge = “departmentCode” is a valid assignment.

myAge = "departmentCode" is not valid because "departmentCode" (with quotes) is a string, myAge datatype is numeric

h. yourRate = deaprtmentCode is not a valid assignment because both values would have to be character values for it to be true or departmentCode must have quotes.

yourRate = departmentCode is not valid since yourate is numberic and departmentcode is char

j. departmentCode = Personnel is not a valid assignment because values for a character variable must be in quotes.

departmentCode = personnel is not valid because personnel is not a variable thus the string must appear in quotes to be assigned to the variable.

l. departmentCode = 413 is not a valid assignment because character variables must equal a constant in quotes.
depaerment code = 413 is valid (yet problematic), the ASCII char represented by the code 413 will be stored in the department code variable

n. departmentCode = myAge is a valid assignment.
departmentcode = myage is valid, however, this will not give expected results, since the department code data type is char and the myAge is numric, in this instance the ASCII code represented by the age variable would be stored in the departmentcode variable, (e.g myAge=12 department code=carrige return).

o. departmentCode = yourRate is a valid assignment
see n.

p. 413 = departmentCode is not a valid assignment because assignments must begin with alphabetic characters.

413 = department code is invalid since 413 is not a variable, or, variablename name must come before data during assignment.

q. “413” = departmentCode is not a valid assignment because a assignments must begin with alphabetic characters.

"413" = depaermentCode is not valid because variablename must come before assigned value, (bad syntax)


I guess I just hope that you understand what I am on about!!!, if you don't then don't worry it will come to you after you've done a few assignments...
 
Thank you root....you have provided very detailed explanations and they have helped greatly.....I am begining to understand this system a bit....i know it will take a while because my teacher is kinda vague on his teaching, but knowing there are people here like you who are willing to help makes me feel a lot better about this semester.

Thanks again!
 
Back
Top Bottom