Question: How do I make the second call of the class NameToAcy with the scanner not return a 0. It wont except the scanner how do

How do I make the second call of the class NameToAcy with the scanner not return a 0. It wont except the scanner how do you get around that?

It almost seems that my classes don't take in a scanner input but only takes in a set value.

public class NameToAcytst { public static void main(String[] args) { Scanner input = new Scanner(System.in) ; NameToAcy t1 = new NameToAcy(""); AcyToSNum t2 = new AcyToSNum(""); double StateNum1 = t2.getNum(t1.getAcy("alabama")) ; System.out.println(StateNum1); NameToAcy h1 = new NameToAcy(""); AcyToSNum h2 = new AcyToSNum(""); System.out.println("Please enter State of alabama"); // the classes attached only work on alabama or it would be to long. //Must be lower case String name = input.next(); double StateNum2 = h2.getNum(h1.getAcy(name)) ; System.out.println(StateNum2); } }

Class NametoAcy

public class NameToAcy { String StateName ; String StateAcy ; String Str ; public NameToAcy (String StateName) { StateName = ""; getAcy(StateName);

} public String getAcy(String StateName) { if ( StateName == "alabama" | StateName == "al" ) { StateAcy = "AL" ; } }

}

This is abriviated to fit within question parameters. if i entered all fifty states it would not fit within question.

public class AcyToSNum { String StateAcy ; double StateNum ; public AcyToSNum (String StateAcy) { StateAcy = ""; this.getNum(StateAcy); } public double getNum(String StateAcy) { if ( StateAcy == "AL" ) { StateNum = 1.0 ; }

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!