Hello guys would someone please help me fix my program. I have two classes the one is named GetValues and the other one is SampleReturn. The GetValues class has an error illegal start of expression in the line public static String kuhaName()
. The code is below.
GetValues class codes:
import java.util.Scanner;
public class GetValues
{
private static Scanner inp = new Scanner(System.in);
private static String z = "";
public static void wew()
{
boolean tryAgain = true;
System.out.print("Enter name: ");
String a = inp.nextLine();
z = a;
do{
System.out.print("Enter password: ");
String pass = inp.nextLine();
if(pass.equals("admin")){
kuhaName();
tryAgain = false;
}
if (!pass.equals("admin")){
System.out.print("Try Again!");
tryAgain = true;
}
}while(tryAgain);
public static String kuhaName()
{
return z;
}
}
}
SampleReturn class code:
public class SampleReturn
{
public static void main(String[]args)
{
GetValues.wew();//First input the name .
String nameMo = GetValues.kuhaName();//Retrieve the name
System.out.print("Your name is: " +nameMo);//Display the name
}
}