import java.util.Scanner;

public class ConvertDate

{

    Scanner console = new Scanner(System.in);
    public static void main(String[] args)
    {
        // Inputs the month, day, and year
        ConvertDate.prompt("Enter date to be converted: ");
        String date = ConvertDate.readLine();
        // Trims the extra spaces
        String dte = date.trim();
        // Creates the minimum space between the characters
        int index1 = dte.indexOf(" ");
        int index2 = dte.lastIndexOf(" ");
        /* This is where the letters of the month are going to be store at in the output as well as capitalizing the first letter
         of the month */
        String firstLetter = dte.substring(0,1);
        String otherLetters = dte.substring(1);
        String dte0 = firstLetter.trim().toUpperCase() + otherLetters.trim().toLowerCase();
        // Trims the extra spaces from the date
         String dte1 = dte0.trim().substring(0, index1);
        String dte2 = dte.trim().substring(index1 + 1, index1 + 4);
        String dte3 = dte.trim().substring(index2 + 1);
        // Gives the output of an accurate date without any extra spaces
        System.out.println("Converted Date: " + dte2 + " " + dte1 + " " + dte3);
    }
}

the error are at ConvertDate.prompt and ConvertDate.readLine and says that create a method prompt(String) and redLine(String) i dont know what to do

Recommended Answers

All 2 Replies

your scanner object is supposed to read input from users, not an object of your class that has not even been decleared
I'd suggest you start again from this point, and ask about any line you add in your code that you are not sure about

import java.util.Scanner;
public class HelloWorld{


     public static void main(String []args){
        System.out.println(getInput());
     }
     public static String getInput(){
         Scanner scanner = new Scanner(System.in);
         return scanner.nextLine();
     }
}

since we don't know the code of ConvertDate, we can't be sure. for all we know, this are static methods in a class calling ConvertDate which has it's own instance of Scanner

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.