Displaying equation and text on same line JAVA

Displaying equation and text on same line JAVA
0

#1

Hey all, I’m taking Java Programming in school right now. Our first assignment is to display the area and perimeter of a circle, with a known radius

The desired result is for the output to be:

Perimeter = 34
Area= 95

I don’t have an issue getting the equation to calculate, I just cant get the text “Perimeter” and the answer “34” on the same line.

Please help!


#2

public class Assign1 {

public static void main(String[] args) {
	// Display output
	System.out.println( 2 * 5.5 * 3.1415);
	System.out.println( 3.1415 * 5.5 * 5.5);

}

}


#3

Can’t you concatenate the string and the answer together? Like

"Perimeter = " + (2 * 5.5 * 3.1415)

#4

This automatically adds a newline:

System.out.println()

This does not:

System.out.print()

So you could do this:

System.out.print("H");
System.out.print("e");
System.out.print("l");
System.out.print("l");
System.out.print("o");
System.out.print(" ");
System.out.print("W");
System.out.print("o");
System.out.print("r");
System.out.print("l");
System.out.println("d");

to get output that looks like
Hello World