Since toString() returns a String, you can format the printed object with %s (see this) but not %f (see this).
You can get the price as a float and print the formatted number along with the brand:
class Car {
public String toString() {
return "I'm a car";
}
public double getPrice() {
return 20000.223214;
}
public String getBrandName() {
return "Brand";
}
}
class Main {
public static void main(String[] args) {
Car c = new Car();
System.out.printf("%10.2f %s", c.getPrice(), c.getBrandName());
}
}
Output
20000.22 Brand
(Represent the price in cents if it's easier.)