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

Recommended Answers

All 2 Replies

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. ":'(

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.