The program is working just fine, but when the last line is printed it'd go like this:
I tried doing it like this,because it's a symbol :
System.out.println(MessageFormat.format("The rectangle\'s area is {0}", area));
But it's still the same result. It'll only work , if I remove the symbol ->" ' ".
And I don't want suggestions of how I should write my the code. Only asking where is my mistake. Thank you
import java.text.MessageFormat;
import java.util.Scanner;
/*4. Rectangles
Write an expression that calculates rectangle’s perimeter and area by given width and height.*/
public class Rectangles {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.print("Please enter width:");
double width = scan.nextDouble();
System.out.print("Please enter height:");
double height = scan.nextDouble();
double area = 2 * width + 2* height;
double perimeter = width*height;
System.out.println(MessageFormat.format("Perimeter {0}",perimeter));
System.out.println(MessageFormat.format("The rectangle's area is {0}", area));
}
}