I have to wrtie a program for class that asks the user to input to cards ex: 7c(7 of clubs) and then compare the two cards at the end to see which one is the greater card. This is the code I have so far and for some reason it does not want to compile for the first card entry. Please help!

public class Program2
{

    public static void main(String[] args)
    {
        String str1;
        System.out.println("Please enter first card: ");
        str1 = SavitchIn.readLine();
        len1 = str1.length();

        if (len1==3)
        {
            char1a=str1.charAt(0);
            char1b=str2.charAt(1);
            char1c=str3.charAt(2);
        }

        else if (len1==2)
        {
            char1a=str1.charAt(0);
            char1b=str2.charAt(1);
        }

        else
        {
            System.out.println("Error");
        }
    }







}

@nandomendoza
Better start using code tags, with already 14 posts you should by now be aware what they are and how to use them, else the days not far before someone gives you bad rep for not using them at all.

Its as simple as putting your code inside [code=java] and [/code].

And as far as your code is concerned what is "SavitchIn" here :-

str1 = SavitchIn.readLine();

I am sure that you must be aware that you need to declare and initialise any variable in Java before using it. Most probably I assume this is a BufferedReader object for reading text from the console.

SavitchIn is a file that was given to me by my professor and this Savitch.readLine displays a line of character when the user inputs something. Do I have the code started right. How would I use a class file and a driver file?

SavitchIn is a file that was given to me by my professor and this Savitch.readLine displays a line of character when the user inputs something.

According to me from what I see you want it to read a line of user input from the console into your String object (str1).
And reading from a console is quite easy using either the java.util.Scanner[ 1 , 2 ] class or the BufferedReader method.

Using the BufferedReader is as simple as :-

BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

// Reads a line from the console
String input = reader.readLine();

There is also a third method (from Java 6 onwards) using the Console class .

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.