Reply
Old 01-30-2012, 04:36 AM   #1 (permalink)
 
Status: Senior Member
Posts: 151,118



Default Beginner Java hmwk help!?

1) Assume that sentence is a variable of type String that has been assigned a value. Assume furthermore that this value is a String consisting of words separated by single space characters with a period at the end. For example: "This is a possible value of sentence."

Assume that there is another variable declared, secondWord , also of type String. Write the statements needed so that the second word of the value of sentence is assigned to secondWord . So, if the value of sentence were "Broccoli is delicious." your code would assign the value "is" to secondWord .

2) Write a sequence of statements that finds the first comma in the String line , and assigns to the variable clause the portion of line up to, but not including the comma. You may assume that an int variable pos , as well as the variables line and clause , have already been declared.

3)
Assume that given , middle and family are three variables of type String that have been assigned values. Write an expression whose value is a String consisting of the first character of given followed by a period followed by the first character of middle followed by a period followed by the first character of family followed by a period: in other words, the initials of the name. So if the values of these three variables were "John" "Fitzgerald" "Kennedy", then the expression's value would be "J.F.K.".

4) With its encoding Java can work with ________ characters.

5) Two variables, num and cost have been declared and given values: num is an integer and cost is a double. Write a single statement that outputs num and cost to standard output. Print both values (num first, then cost), separated by a space on a single line that is terminated with a newline character. Do not output any thing else.

6) Assume that name and age have been declared suitably for storing names (like "Abdullah", "Alexandra" and "Zoe") and ages respectively. Assume also that stdin is a variable that references a Scanner object associated with standard input. Write some code that reads in a name and an age and then prints the message "The age of NAME is AGE" on a line by itself, where NAME and AGE are replaced by the values read in for the variables name and age.
For example, if your code read in "Rohit" and 70 then it would print out "The age of Rohit is 70" on a line by itself. There should NOT be a period in the output.

7) Assume that name has been declared suitably for storing names (like "Misha", "Emily" and "Sofia"). Assume also that stdin is a variable that references a Scanner object associated with standard input Write some code that reads a value into name then prints the message "Greetings, NAME" on a line by itself, where NAME is replaced the value that was read into name.
For example, if your code read in "Rachel" it would print out "Greetings, Rachel" on a line by itself.

8)Assume that name has been declared suitably for storing names (like "Amy", "Fritz" and "Moustafa"). Assume also that stdin is a variable that references a Scanner object associated with standard input. Write some code that reads a value into name then prints the message "Greetings, NAME!!!" on a line by itself where NAME is replaced the value that was read into name.
For example, if your code read in "Hassan" it would print out "Greetings, Hassan!!!" on a line by itself.

9) Three business partners are forming a company whose name will be of the form "Name1, Name2 and Name3". However, they can't agree whose name should be first, second or last. Help them out by writing code that reads in their three names and prints each possible combination exactly once, on a line by itself (that is, each possible combination is terminated with a newline character). Assume that name1, name2 and name3 have already been declared and use them in your code. Assume also that stdin is a variable that references a Scanner object associated with standard input.
For example, if your code read in "Larry", "Curly" and "Moe" it would print out "Larry, Curly and Moe", "Curly, Larry and Moe", etc., each on a separate line.

10) Assume that dateManager is a reference to an object that has a method named printTodaysDate , that accepts no arguments and returns no value. Write a statement that calls printTodaysDate .

11) Assume that dataTransmitter is a variable that refers to an object that provides a method, named sendNumber . There is one int argument for this method. Invoke this method and use the number 5 as an argument.



12)Assume that arithmetic is a reference to an object that has a method named add , that accepts two int arguments and returns their sum.
Unknown_User is offline   Reply With Quote
Old 01-30-2012, 04:36 AM   #2 (permalink)
 
Status: Junior Member
Posts: 2



Default Beginner Java hmwk help!?

Tl;dr sorry, make it shorter. I"ll be around
MSK12 is offline   Reply With Quote
more..
Old 01-30-2012, 04:36 AM   #3 (permalink)
 
Status: Senior Member
Posts: 353



Default Beginner Java hmwk help!?

Make the question shorter and I'll answer it. Cause no body wants to read all that.
Ashley is offline   Reply With Quote
Old 01-30-2012, 04:36 AM   #4 (permalink)
 
Status: Senior Member
Posts: 151,118



Default Beginner Java hmwk help!?

Are there one or two questions you most specifically need help with, or is just all 12 you have no idea?
Unknown_User is offline   Reply With Quote

Reply

Bookmarks

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Java hmwk help!? yishunshin Programming Languages 0 03-07-2014 02:05 AM
Java programming hmwk help. Done with overall, just need help on last part.? ace Billing Coding 0 09-16-2013 02:05 AM
c programming hmwk help? ace Programming 0 03-11-2013 03:04 AM
c programming hmwk (need help)? ace Coding 1 03-06-2013 09:04 PM
c programming hmwk (need help)? ace Coding 1 03-04-2013 06:06 AM