Go Back   Computer Forums > Web Design | Website Development > Web Programming
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 09-04-2006, 07:56 PM   #1
Solid State Member
 
Join Date: Sep 2006
Posts: 10
Default Homework Help #1

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!!!
__________________

ascendantofrain is offline   Reply With Quote
Old 09-04-2006, 09:48 PM   #2
BSOD
 
Join Date: Aug 2006
Posts: 39
Default Re: Homework Help #1

Going through it, it all seems pretty good

what programming are you doin anyhow?
__________________

pcfan734 is offline   Reply With Quote
Old 09-04-2006, 10:09 PM   #3
Solid State Member
 
Join Date: Sep 2006
Posts: 10
Default Re: Homework Help #1

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.
ascendantofrain is offline   Reply With Quote
Old 09-05-2006, 05:58 AM   #4
Site Team
 
root's Avatar
 
Join Date: Mar 2004
Posts: 8,004
Default Re: Homework Help #1

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...
__________________
I didn’t fight my way to the top of the food chain to be a vegetarian…
Im sick of people saying 'dont waste paper'. If trees wanted to live, they'd all carry guns.
"The inherent vice of capitalism is the unequal sharing of blessings; The inherent vice of socialism is the equal sharing of miseries."
root is offline   Reply With Quote
Old 09-05-2006, 04:51 PM   #5
Solid State Member
 
Join Date: Sep 2006
Posts: 10
Default Re: Homework Help #1

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!
ascendantofrain is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 09:23 AM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0