LiveWire Network Peer Answers Peer Support Teen Forums Tech Forums College Forums 383 users online 221636 members 134 active today Advertise Here Sign In
TeenCollegeTechPhotos | Quizzes | LiveSecret | Memberlist | Dictionary | News | FAQ
Member Spotlight
datkidagain
I haven't filled out my profile...
Days Active: 1
You have 1 new message.
Emergency Help
Until you sign up you can't do much. Yes, it's free.

Sign Up Now
Membername:
Password:
Already have an account?
Invite Friends
Active Members
Groups
Contests
Moderators
2 online / 40 MPM
Fresh Topics
  LiveWire / Technical Forums / Programming & Application Development / Viewing Topic

Help with Java
Replies: 6Last Post Sep. 12, 2008 2:25pm by Majo
Welcome to LiveWire!
We're Stronger Together.
Join the Community
Single page for this topic Email Print Favorite
( Majo )


Soothsayer
Reply
I need to get I don't know how many different things to print out on different lines. How should I go about doing this? What would be the best way? I don't know if I should do it line by line like:

Code:
System.out.println("Hello");
System.out.println("Goodbye");

...or not because that's not really efficient, right? And we have to use the proper print function, as well, and I'm not sure if that's it. It'd also be nice if I could do it without stretching my page out like a mile long just to code it properly...

-------
"Under the hardness of her facade a woman's heart is still beating."


2:05 pm on Sep. 12, 2008 | Joined: May 2005 | Days Active: 301
Join to learn more about Majo Pennsylvania, United States | Straight Female | Posts: 6,733 | Points: 10,531
LiveWire Humor
marshmellowman


wewerepromisedjetpacks

Patron
Support Leader
Tech Support Leader
Reply
Does the \n work like in C++? So you'd have:
Code:
System.out.println("Hello\nGoodbye");


-------
and victorious in war shall be made glorious in peace.

2:08 pm on Sep. 12, 2008 | Joined: Feb. 2007 | Days Active: 755
Join to learn more about marshmellowman England, United Kingdom | Straight Male | Posts: 24,315 | Points: 43,025
( Majo )


Soothsayer
Reply
It does but I'm not sure how to use it. I got two lines to print out separately but then it all fell apart. I need to do something like this:

Code:
System.out.println("Car make and model: Volkswagen Golf"\n "Expected Annual Mileage: " + mileage);

Assuming that's right, that's as far as I got before I couldn't figure out what to do next. Next, I need to add in something like:

Code:
("Cost of a gallon of gas: " + gallon)

But I don't know how to get that in there.

-------
"Under the hardness of her facade a woman's heart is still beating."


2:15 pm on Sep. 12, 2008 | Joined: May 2005 | Days Active: 301
Join to learn more about Majo Pennsylvania, United States | Straight Female | Posts: 6,733 | Points: 10,531
marshmellowman


wewerepromisedjetpacks

Patron
Support Leader
Tech Support Leader
Reply
The \n actually has to be within the text, no outside the quotes. So yours would be like:
Code:
System.out.println("Car make and model: Volkswagen Golf \n Expected Annual Mileage: " + mileage "\n Cost of a gallon of gas:" + gallon);
That's how I remember it anyway for C++, it might be different for Java, I'm not too sure.

-------
and victorious in war shall be made glorious in peace.

2:20 pm on Sep. 12, 2008 | Joined: Feb. 2007 | Days Active: 755
Join to learn more about marshmellowman England, United Kingdom | Straight Male | Posts: 24,315 | Points: 43,025
( Majo )


Soothsayer
Reply
Alright, I'll give that a go and see what happens when I try to compile it, thanks.

-------
"Under the hardness of her facade a woman's heart is still beating."

2:23 pm on Sep. 12, 2008 | Joined: May 2005 | Days Active: 301
Join to learn more about Majo Pennsylvania, United States | Straight Female | Posts: 6,733 | Points: 10,531
ampamp


Professional
Reply
The \n has to be inside the " marks. I don't see any reason to use them, when printing things out. I would just put them into indiviual println, to make it easier to read later.

-------
miimii *_____*

2:23 pm on Sep. 12, 2008 | Joined: Sep. 2007 | Days Active: 185
Join to learn more about ampamp Sweden | Straight Male | Posts: 944 | Points: 2,830
( Majo )


Soothsayer
Reply
I don't know if that's "proper" or not, though.

Gah, I think I'll quit this one and email the professor to see what he wants, my back is killing me and I'm hungry anyways.

-------
"Under the hardness of her facade a woman's heart is still beating."


2:25 pm on Sep. 12, 2008 | Joined: May 2005 | Days Active: 301
Join to learn more about Majo Pennsylvania, United States | Straight Female | Posts: 6,733 | Points: 10,531
Single page for this topic Email Print Favorite

Quick Reply

You are signed in as our guest.

Looking for something else?
 

  LiveWire / Technical Forums / Programming & Application Development / Viewing Topic