Graderpractice for programmers

Back to 254275 OOP - Mini Test 2 (Sec 3 & 4)

3. Add getPriceRange method

Problem

Reuse your Watch class from question 1. Add a method named getPriceRange that returns a String. If the price is less than 1000 then it is "Budget", if it is greater than 10000 then it is "Executive", else it is "Regular".

Test code:

class MT2bTask3 {
    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        Watch w = input();

        System.out.print(w.getName() + " is ");
        System.out.println(w.getPriceRange());
    }

    private static Watch input() {
        String name = sc.nextLine();
        String colour = sc.nextLine();
        int price = Integer.parseInt(sc.nextLine());
        return new Watch(name, colour, price);
    }
}

Examples

Input

Guess
Rose Gold
7600

Output

Guess is Regular

Input

Baby G 120
White
990

Output

Baby G 120 is Budget

Submit your solution

java