Here i need to write this code for class and i am getting the missing return statement error. Heres my code :

import java.util.Scanner;
import java.text.DecimalFormat;

public class derived extends Foreign
{
    Scanner keyboard = new Scanner(System.in);
        private String date;

        public void vertDisplay()
        {
            super.vertDisplay();
            System.out.println("Date = " + date);
        }
        public double inputDollars()
        {
            super.inputDollars();
            System.out.println("Please enter todays date. 00.00.00");
            date = keyboard.nextLine();
}

}

Im not sure why it is doing this but if i delete the last part and make it like this...

import java.util.Scanner;
import java.text.DecimalFormat;

public class derived extends Foreign
{
    Scanner keyboard = new Scanner(System.in);
        private String date;

        public void vertDisplay()
        {
            super.vertDisplay();
            System.out.println("Date = " + date);
        }
}

then it works fine. Could someone please help me

Edited 3 Years Ago by mike_2000_17: Fixed formatting

In the first version you declared that the method returned a double value, but it does not return anything at all - hence that "missing return statement". If your method declares a return type, it has to return a value of that type.

Thank you for you quick responce and the great help. "I hate it when its somthing stupid like that. ":'(

This article has been dead for over six months. Start a new discussion instead.