Graderpractice for programmers

254275 OOP - Mini Test 1 (Sec 3 & 4)

Awaiting submission
Read in an integer. If it is 1 digit (0-9) then print "single". If it is 2 digits (10-99) then print "double". Else print "other".
Awaiting submission
The triple sequence is 3, 6, 9, 12, 15, 18, 21, ... 3*n. Read in the number n and print out the sequence of triple numbers up to the n-th item.
Awaiting submission
Read in an integer x. Print a large letter L using asterisk (*). It should have a line of x asterisks at the left and bottom.
Awaiting submission
Read in a list of words. For each word, print out the second, third and fourth characters. When the program reaches the word "quit" then stop.
Awaiting submission
A house has a living room, a kitchen, X bedrooms and Y toilets. Complete the House class by writing 3 methods:
  • getBedrooms returns the number of bedrooms X
  • getToilets returns the number of toilets Y
  • getTotal returns the total number of rooms (X + Y + 2)

Submit the House.java file ONLY!

Template:
class House {
    private int bedrooms;
    private int toilets;

    public House(int bedrooms, int toilets) {
        this.bedrooms = bedrooms;
        this.toilets = toilets;
    }
}
Test code:
class TestE {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        House h = new House(sc.nextInt(), sc.nextInt());
        System.out.println("My house has " + h.getTotal() + " rooms including " + h.getBedrooms() + " bedrooms and " + h.getToilets() + " toilets.");
    }
}