السلام عليكم
معليش طلبت منا الأستاذة هذا الواجب بس ما أدري اش الغلط الموجود فيه ؟؟
الطلب الأول : أني أدخل الاسم كاملا
الطلب الثاني : آخذ الحرف الثاني من (اسم الأول و اسم الأب واسم الجد ) فلو كان الاسم كاملا :sara yiui gthj
بعد انشاء متغير يصبح ait
وأيضا تريد من البرنامج أن يختار رقم عشوائي من 0-1.0
باستخدام float والكلاس Random
import java.util.*;
import java..*;
import java.lang.*;
public class HW2 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in );
String fullName,first,rest1,rest,a,b,c ;
System.out.print("Enter your full name :");
fullName = scanner.nextLine();
a=fullName.substring(1,2);
rest1 = fullName.substring(fullName.indexOf(" ")+1,fullName.length());
b=rest1.substring(1,2);
rest = rest1.substring(rest1.indexOf(" ")+1,rest1.length());
c=rest.substring(1,3);
System.out.println("The first part of account user Name will be\t:"+a+b+c);
// date
Date today;
today=new Date();
SimpleDateFormat sdf;
sdf=new SimpleDateFormat("ddMMyyyy");
System.out.println("The second part of the account user name will be : "+ sdf.format(today));
// random
Random random=new Random ();
int ra = random .nextInt(5)+1;
System.out.print ("A random integer from 1 to 5 is "+ ra);
float tt= (float)1.0;
float rf =random .nextFloat(tt);
System.out.print ("A random float from 0.0 to 1.0 is "+ rf);
}
}