Hi,

I have been practising some OOP and have encountered this error
" cannot resolve symbol - variable MyInput"

I wonder wat's wrong...here is part of my code:

public class BorrowMortgage
{
//Main method
public static void main (String[] args)
{
//Create one borrower
Borrower borrower = new Borrower( );


//Enter the information for the borrower
//1. Enter name
Name name = new Name ( );
System.out.print("Enter first name: ");
String firstname = MyInput.readString ( );
name.setFirstname(firstname);


System.out.print("Enter mi: ");
String mi = MyInput.readString ( );
name.setMi(mi);


System.out.print("Enter last name: ");
String lastname = MyInput.readString ( );
name.setLastname(lastname);


//2. Enter address


Address address = new Address ( );
System.out.print("Enter street: ");
String street = MyInput.readString ( );
address.setStreet(street);


System.out.print("Enter city: ");
String city = MyInput.readString ( );
address.setCity(city);


System.out.print("Enter state: ");
String state = MyInput.readString ( );
address.setState(state);


System.out.print("Enter zip: ");
String street = MyInput.readString ( );
address.setZip(zip);


//3. Enter mortgage information
Mortgage mortgage = new Mortgage ( );
System.out.print ("Enter annual interest rate (i.e 7.25): ");
double annualInterestRate = MyInput.readDouble( );
mortgage.setAnnualInterestRate(annualInterestRate);


System.out.print("Enter number of years:");
int numOfYears = MyInput.readDouble ( );
mortgage.setLoanAmount (loanAmount);


//4. Set values to the borrower
borrower.setName(name);
borrower.setAddress(address);
borrower.setMortgage(mortgage);


//Print mortgage information
System.out.print(borrower.toString( ) );
}
}

can anybody help me? thanks!!

I'm betting this is a compile error?

Your compiler can't find the class MyInput. Make sure that MyInput is in your classpath.

Regards,

Nate

I'm betting this is a compile error?

Your compiler can't find the class MyInput. Make sure that MyInput is in your classpath.

Regards,

Nate

Yep. You're using a third party class to read input. I'm guessing it's either came with a book, or your teacher supplied it. Either way you need to have it, because it's not normally in the java subset.

hmmm....

link your program to MyInput class.

have fun

brother you are using MyInput in JDK 1.5, u can't use with it for console input u should use Scanner class

import java.util.*;
Scanner scanner = new Scanner(System.in);

Well assuming that the other peoples comments are correct then you can create an instance of the class "MyInput." Like say:

MyInput input = new MyInput();

This will allow you utilise the methods available in that class; as you probable already know?

Dear
To use MyInput class you should copy MyInput.class in the same folder where u saved your file,

commented: Thank you Brother i was also find using MyInput you answer help me soo much we have done but i donot have remember that is why i was finding +0

Dear
To use MyInput class you should copy MyInput.class in the same folder where u saved your file,

MyInput.java file

// MyInput.java: Contain the methods for reading int, double, and
// string values from the keyboard
package chapter2;

import java.io.*;

public class MyInput {
  /** Read a string from the keyboard */
  public static String readString() {
    BufferedReader br = 
      new BufferedReader(new InputStreamReader(System.in), 1);

    // Declare and initialize the string
    String string = " ";

    // Get the string from the keyboard
    try {
      string = br.readLine();
    }
    catch (IOException ex) {
      System.out.println(ex);
    }

    // Return the string obtained from the keyboard
    return string;
  }

  /** Read an int value from the keyboard */
  public static int readInt() {
    return Integer.parseInt(readString());
  }

  /** Read a double value from the keyboard */
  public static double readDouble() {
    return Double.parseDouble(readString());
  }

  /** Read a byte value from the keyboard */
  public static byte readByte() {
    return Byte.parseByte(readString());
  }

  /** Read a short value from the keyboard */
  public static short readShort() {
    return Short.parseShort(readString());
  }

  /** Read a long value from the keyboard */
  public static long readLong() {
    return Long.parseLong(readString());
  }

  /** Read a float value from the keyboard */
  public static float readFloat() {
    return Float.parseFloat(readString());
  }

  /** Read a character from the keyboard */
  public static char readChar() {
    return readString().charAt(0);
  }
}