Java/מחרוזות/תרגילים: הבדלים בין גרסאות בדף

תוכן שנמחק תוכן שנוסף
Johnny Zoo (שיחה | תרומות)
מאין תקציר עריכה
Johnny Zoo (שיחה | תרומות)
מ תיקון באג פוטנציאלי
שורה 2:
 
==קליטה==
כתבו תוכנית פשוטה, שתאתחל משתנה מסוג string, ותקלוט עבורו ערך מהמשתמש. רמז: כדי לקלוט מחרוזת, השתמשו ב-Scanner ובמקום nextInt, כתבו פשוט nextnextLine.
{{מוסתר|פתרון|2=
<div style="text-align:left; direction:ltr;">
שורה 15:
Scanner s = new Scanner(System.in);
 
str = s.nextnextLine();
}
 
שורה 38:
 
System.out.print("What is your name? ");
str = s.nextnextLine();
System.out.println("Hello, "+str);
}
שורה 62:
 
System.out.print("What is your name? ");
str = s.nextnextLine();
System.out.print("What is your family name? ");
str2 = s.nextnextLine();
fullName = str+" "+str2;
len = fullName.length()-1;