| Replies
|
|
|
Majo
|
Posted at 2:25 pm on Sep. 12, 2008 |
| 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. |
|
|
ampamp
|
Posted at 2:23 pm on Sep. 12, 2008 |
| 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. |
|
|
Majo
|
Posted at 2:23 pm on Sep. 12, 2008 |
| Alright, I'll give that a go and see what happens when I try to compile it, thanks. |
|
|
marshmellowman
|
Posted at 2:20 pm on Sep. 12, 2008 |
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. |
|
|
Majo
|
Posted at 2:15 pm on Sep. 12, 2008 |
| 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. |
|
|
marshmellowman
|
Posted at 2:08 pm on Sep. 12, 2008 |
Does the \n work like in C++? So you'd have: | Code: | | System.out.println("Hello\nGoodbye"); | |
|
|
All 6 previous replies displayed. |