• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

One more nooby Java question

B.def

Member
Sorry to bug everyone with these questions, so this is my last one.

Today in class we were assigned this problem.

Write a program that does the following
a. Declare a character and a string variable and assign initial values to them.
b. Print the values of both the variables on one line separated by a space character.
c. Use two Java statements to print your full name in one line.
d. Use only one statement to print your address in two lines.

What I dont understand is how to declare the string variable, what type of initial value he wants, and what it means by use two java statements to print my name.

Thanks in advance for any help.
 
Thanks, but the link given doesn't really explain declaring a string and that's where I'm the most confused at. I don't even know where to begin.

This is my first guess

Code:
//Part a.
char x = 5;
String y = "This is a string";
//Part b.
System.out.println(x+" "+y);
//Part c.
System.out.print("Brendan ") System.out.println("DeForest");
//Part d.
System.out.println("XXXX Wayne St. \n Fort Wayne, IN");

I feel like I'm suppose to use the variables declared in part a for the rest of the steps.
 
Last edited:
Looks like you got it correct minus some syntax. You need a ; between the printing your 1st and last. I would make your last name use println instead of print for formatting.

Should is be String instead of string?

Also in a public forum I would change your name and street to something else.

Edit: I see you made some corrections =D while I was responding.
 
haha yes I caught myself in a few mistakes, but you verified my corrections to be right.
As far as my name and city I'm not too worried about, but thanks for the advice.

Thanks for your help though man.

Edit:Just verified with the professor and he says everything looks good! 😀
 
Last edited:
Back
Top