คุณส่ง
public class UseCarPrice {
public static void main(String[] args) {
CarPrice car = new CarPrice();
double sedanPrice = car.calSedan(550000.00);
System.out
.println
("Total price of sedan: " + sedanPrice
);
double pickupPrice = car.calPickup(380000.00);
System.out
.println
("Total price of pick up: " + pickupPrice
); }
}
class CarPrice {
public double calSedan(double price) {
double netPrice = price + (price * 0.05);
return netPrice;
}
public double calPickup(double price) {
double netPrice = price + (price * 0.03);
return netPrice;
}
}
CuC4hOC4uOC4k+C4quC5iOC4hwpwdWJsaWMgY2xhc3MgVXNlQ2FyUHJpY2UgewogICAgcHVibGljIHN0YXRpYyB2b2lkIG1haW4oU3RyaW5nW10gYXJncykgewogICAgICAgIENhclByaWNlIGNhciA9IG5ldyBDYXJQcmljZSgpOyAKCiAgICAgICAgZG91YmxlIHNlZGFuUHJpY2UgPSBjYXIuY2FsU2VkYW4oNTUwMDAwLjAwKTsKICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oIlRvdGFsIHByaWNlIG9mIHNlZGFuOiAiICsgc2VkYW5QcmljZSk7CgogICAgICAgIGRvdWJsZSBwaWNrdXBQcmljZSA9IGNhci5jYWxQaWNrdXAoMzgwMDAwLjAwKTsKICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oIlRvdGFsIHByaWNlIG9mIHBpY2sgdXA6ICIgKyBwaWNrdXBQcmljZSk7CiAgICB9Cn0KCmNsYXNzIENhclByaWNlIHsKICAgIHB1YmxpYyBkb3VibGUgY2FsU2VkYW4oZG91YmxlIHByaWNlKSB7CiAgICAgICAgZG91YmxlIG5ldFByaWNlID0gcHJpY2UgKyAocHJpY2UgKiAwLjA1KTsgCiAgICAgICAgcmV0dXJuIG5ldFByaWNlOwogICAgfQoKICAgIHB1YmxpYyBkb3VibGUgY2FsUGlja3VwKGRvdWJsZSBwcmljZSkgewogICAgICAgIGRvdWJsZSBuZXRQcmljZSA9IHByaWNlICsgKHByaWNlICogMC4wMyk7IAogICAgICAgIHJldHVybiBuZXRQcmljZTsKICAgIH0KfQ==