Graderpractice for programmers

254275 OOP - Practice before Mini Test 1

Awaiting submission
Print the numbers 1 2 3 on separate lines
Awaiting submission
Read in a number and check if it is divisible by 3. Output "Y" when it is divisible and "N" when it is not.
Awaiting submission
Read in a string and print its characters in reverse order.
Awaiting submission
Read in an integer and print a diagonal line (north east to south west) using asterisks/stars (*).
Awaiting submission
Car registration plates in the UK must be 7 or fewer characters (e.g. A1, BC23, D4567EF, 89GHIJ). Read in a list of registration plates and output only the correct ones. Do not output empty lines. The end of the input is the word "quit".
Awaiting submission
Read in a list of 5 numbers and check that they are in ascending order
Awaiting submission
Read in a string and an integer. Print out the x-th character of the string, where x is the integer from the user input. If the integer is greater than the length of the string then print "error".
Awaiting submission
A car consists of a model (String) and a speed (int). If the speed is greater than 200 km/h then it is a "fast" car. Complete the Car class by writing 3 methods:
  • getModel() returns the model (String)
  • getSpeed() returns the speed (int)
  • isFast() returns true if the speed is greater than 200 (boolean)

Submit the file ONLY!

class Car {
    // Variables
    private String model;
    private int speed;

    // Constructor
    public Car(String model, int speed) {
        this.model = model;
        this.speed = speed;

    // Methods

Test code
import java.util.Scanner;

class Test {
    public static void main(String[] args) {
        Scanner sc = new Scanner(;
        Car c = new Car(sc.nextLine(), sc.nextInt());
        System.out.println(c.getModel() + " has a speed of " + c.getSpeed() + "km/h");
        if (c.isFast()) {
            System.out.println("It's a supercar!");