السلام عليكم
لو سمحتم يا اخوان
هذا الكود مثال
يطلب ادخال
month/day/year
ثم يقوم بطباعة التارخ بيالترتيب التالي
day/month/year
public class DateRecognizerV1 {
public static void main( String [] args ) {
System.out.println("PMJ's DateRecognizerV1...");
Scanner Input = new Scanner(System.in);
String S;
final String DELIMITER = "/";
int month, day, year;
int first, last;
System.out.print("Enter a date:");
S = Input.nextLine();
S = S.trim();
first = S.indexOf(DELIMITER);
last = S.lastIndexOf(DELIMITER);
month = Integer.toString(S.substring(0,first).trim());
day = Integer.toString(S.substring((first+1),last).trim());
year = Integer.toString(S.substring(last+1).trim());
System.out.println("Thus the " + month + " day, of the " + day + " month, of the " + year + " year!!!");
}
}
import java.util.Scanner;
هذا الكود بعد التعديل
عند ادخال البيانات لا زم تكون على الشكل التالي
Last name, First name, Designation, Department
مثال
Kubika, Jon M., Faculty, Computer Information Syteme
يقوم البرنامج بضم الاسم الاول واسم العائلة ويمسح الفاصلة بين الاسمين
ثم يقوم بطباعة بهذ الشكل
First name Last name, Designation, Department
Jon M. Kubika, Faculty, Computer Information Syteme
الكود شغال تمام
بس فية مايأدي المطلوب مدري وش الغلط الرجاء المساعدة
public class InfoRmation{
public static void main( String [] args ) {
System.out.println("PMJ's AS02V1...");
Scanner Input = new Scanner(System.in);
String S;
final String COMMA = ",";
String last_name, first_name, full_name, designation, department;
int first, last;
S = Input.nextLine();
S = S.trim();
first = S.indexOf(COMMA);
last = S.lastIndexOf(COMMA);
first_name = S.substring(0,first).trim();
last_name = S.substring(0,first).trim();
full_name = first_name.concat (" "+last_name);
designation = S.substring((first+1),last).trim();
department = S.substring(last+1).trim();
System.out.println(full_name + ", " + designation + ", " + department);
}
}
import java.util.Scanner;