我怎样才能写出一个更好的代码(比较)

How can I write a code which gives which one is better (comparing)

给定一辆汽车具有以下特征: - 年龄(年龄) - BGN 价格(价格) 车龄超过 5 年且价格超过 20 的汽车是高端车 千年或 5 年或更短时间,成本超过 40,000 写出判断车辆是否为给定特征的表达式 高端。 我试过 :

import java.util.Scanner;

 public class Vehicle {

public static void main(String[] args) {
    // TODO Auto-generated method stub
    Scanner input = new Scanner(System.in);
    System.out.println("Age: ");
    int age = input.nextInt();

    Scanner input1 = new Scanner(System.in);
    System.out.println("Price: ");
    int price = input1.nextInt();
       boolean isHightClass = age >= 5 && price > 20000 || age <= 5 && price > 4000;
    System.out.println(isHightClass);

可以吗?

尝试这样写:

boolean isHightClass = (age >= 5 && price > 20000) || (age <= 5 && price > 4000);

您正在检查价格是否大于 4,000,而不是您问题中所说的 40,000。