import java.util.Scanner;
public class Initials {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String firstIni,
secondIni,
thirdIni;
System.out.print("Enter First Initial: ");
firstIni = input.next();
System.out.print("Enter Second Initial: ");
secondIni = input.next();
System.out.print("Enter Third initial: ");
thirdIni = input.next();
System.out.println( thirdIni + secondIni + firstIni );
} // end main()
} // end class Initials
Scanner input = new Scanner( System.in);
give the semicolon after the bracket and its System.in not System.in.
ps-- if you are printing initials why are you taking the variables as integers?
You need to create a class for it to work.
For example:
public class MyJava {
//your main code goes here
}
check here: http://tswebschool.com/java/java_objects...
I I'm using this in jGRASP
public static void main (String [] args)
{
Scanner input = new Scanner( System.in.;)
int firstini,
secondini,
thirdini;
System.out.print("Enter First Initial: ");
int Firstini = Scan.next();
System.out.print("Enter Second Initial: ");
int Secondini = Scan.next();
System.out.print("Enter Third initial: ");
int Thirdini = Scan.next();
System.out.println( ThirdIni + SecondIni + FirstIni );
}
}
To try and write a program that prints the initials I enter in reversed order of how I entered them. But I keep getting this error message,
asig5.java:6:
Scanner input = new Scanner( System.in.;)
^
asig5.java:6: ';' expected
Scanner input = new Scanner( System.in.;)
^
2 errors
----jGRASP wedge: exit code for process is 1.
----jGRASP: operation complet
How can I fix this?