0 evaluări0% au considerat acest document util (0 voturi)
12 vizualizări1 pagină
Import java.util.Scanner; public class StarMethod. Scan = new scanner (System.in); int indexOf = 0; of stars String yesNo = ""; System.out.println("Enter something."); user = scan.nextLine().
Import java.util.Scanner; public class StarMethod. Scan = new scanner (System.in); int indexOf = 0; of stars String yesNo = ""; System.out.println("Enter something."); user = scan.nextLine().
Drepturi de autor:
Attribution Non-Commercial (BY-NC)
Formate disponibile
Descărcați ca TXT, PDF, TXT sau citiți online pe Scribd
Import java.util.Scanner; public class StarMethod. Scan = new scanner (System.in); int indexOf = 0; of stars String yesNo = ""; System.out.println("Enter something."); user = scan.nextLine().
Drepturi de autor:
Attribution Non-Commercial (BY-NC)
Formate disponibile
Descărcați ca TXT, PDF, TXT sau citiți online pe Scribd
{ public static void main(String[] args) { Scanner scan = new Scanner (System.in); //imports scanner String user = ""; //userinput int indexOf = 0; //the number for the index of stars String yesNo = ""; //true or false value
System.out.println("Enter something."); //asks user for input
user = scan.nextLine(); //scans info
if (user.length()<0||user.indexOf('*')<0) //if a string does not
have any info and no star yesNo = "false"; //returns false else if (user.length()>0&&user.indexOf('*')>0)//if it does yesNo = "true"; //returns true