/**
 * Simulation of a car, with methods to read the
 * car data and to convert the car data to a String
 */
import java.util.*;

public class Car1 {

    public String owner;   // owner's name
    public String license; // license plate
    public int speed;      // current speed

    /**
     * Read the data for a car from the user,
     * using screen prompts and scanner input.
     */
    public void readInput() {
        Scanner keyboard = new Scanner(System.in);
        System.out.println("Who is the owner of the car?");
        owner = keyboard.nextLine();

        System.out.println("What is the license plate?");
        license = keyboard.nextLine();

        System.out.println("What is the speed?");
        speed = keyboard.nextInt( );

        /*
         * Keep reading speed until user enters
         * a nonnegative number
         */
        while (speed < 0) {
            System.out.println("Speed cannot be negative.");
            System.out.println("Reenter speed:");
            speed = keyboard.nextInt();
        }
    }

    /**
     * Return a String containing the car data
     */
    public String toString() {
        String carData = "Owner: " + owner + "\n";
        carData += "License: " + license + "\n";
        carData += "Speed = " + speed + "\n";

        return carData;
    }
}