Graderpractice for programmers

Back to 254275 OOP Lab 5-10

Q13. 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:


    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

Submit your solution

java