Graderpractice for programmers

254275 OOP - Mini Test 1 (re-run)

Awaiting submission
Read in an integer. If it is divisible by 100 then print "100s". If it is divisible by 10 then print "10s". Else print "1s".
Awaiting submission
The cube sequence is 1, 8, 27, 64, 125, ... n*n*n. Read in the number n and print out the sequence of cubes up to the n-th item.
Awaiting submission
Read in an integer x. Print a large letter O using asterisk (*). It should have a line of x-2 asterisks at the top, left, right and bottom with a dot in each corner. Assume x is greater than 2.
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.");
    }
}