Hi, i need help with this qustion
i solved ,but i dont know how i can get full address like this 11th street, nakheel
Problem
* Design and implement a Student class.
a. Each student has the following Data Fields:
* studentFirstName,
* studentLastName,
* studentAddress,
* studentBloodGroup
must be: A, A-, B, B-, AB, AB-, O or O-. Nothing else.
* studentCity.
b. What are the types of these Data?
* Write the following elements :
* Write a Constructor to initialize the values of the Data Fields (attributes).
* Write Accessor and Mutator methods for each data.
* Write a tostring() method to print all the student information’s to standard output.
* Create a main class called StudentDemo.java that uses the student class.
a. Read student info’s from an input file students.txt and create a student object.
* Sample file
: Students.txt
200912345 marya velardi 11th street, nakheel A+ soule
201023456 rechard sosemy zayed street, tawiya O sydeny
201124456 roby vela teniji matter road, lissali B+ lass vegas
 
b. Write a method that generates for a student a file named id.txt that contents same as the following example:
* 200912345.txt
Student Id: 200912345
Student name: marya velardi
Address: 11th street, nakheel
City: soule
BloodType: A+
thats my solution :
package student;public class Student {
private String Name;
private String FName;
private String LName;
private String StudentAddress;
private String Sbloodtype;
private String Studentcity;
private String ID;
public Student() {
}
public Student(String FtName, String LtName, String StudentAddress, String Sbloodtype, String Studentcity, String ID) {
this.FName = FtName;
this.LName = LtName;
this.StudentAddress = StudentAddress;
this.Sbloodtype = Sbloodtype;
this.Studentcity = Studentcity;
this.ID = ID;
}
//use Accessor and Mutator methods
public String getFtName() {
return FName;
}
public void setFtName(String FtName) {
this.FName = FtName;
}
public String getLtName() {
return LName;
}
public void setLtName(String LtName) {
this.LName = LtName;
}
public String getStudentAddress() {
return StudentAddress;
}
public void setStudentAddress(String StudentAddress) {
this.StudentAddress = StudentAddress;
}
public String getSbloodtype() {
return Sbloodtype;
}
public void setSbloodtype( String Sbloodgroup) {
this.Sbloodtype = Sbloodgroup;
}
public String getStudentcity() {
return Studentcity.toString();
}
public void setStudentcity(String Studentcity) {
this.Studentcity = Studentcity;
}
public String getID() {
return ID;
}
public void setID(String ID) {
this.ID = ID;
}
//tostring method to print all the student information’s
public String toString() {
return "Student{" + "FtName=" + FName + ",\n\t LtName=" + LName + ", StudentAddress=" + StudentAddress + ", Sbloodtype=" + Sbloodtype + ", Studentcity=" + Studentcity + ", ID=" + ID + '}';
}
}
anthor class :
package student;
import java.io.*;
import java.util.Scanner;
public class StudentDemo {
public static void main(String[] args) throws FileNotFoundException {
Scanner inFile = new Scanner(new FileReader("student.txt"));
PrintWriter outFile = new PrintWriter("id.txt");
//declare variables
String ID;
String FName;
String LName;
String StudentAddress;
String SCity;
String bloodtype;
//read from student file ID = inFile.next();
FName = inFile.next();
LName = inFile.next(); StudentAddress = inFile.next(); // how can i use while loop here in address
SCity = inFile.next();
bloodtype = inFile.next();
outFile.println("Student ID :" + (ID));
outFile.println("Student name:" + (FName) + " " + (LName));
outFile.println("Address :" + StudentAddress);
outFile.println("City :" + SCity);
outFile.println("blood type :" + bloodtype);
inFile.close();
outFile.close();
}
}
when i run the program i got this :
Student ID :200912345
Student name:marya velardi
Address :11th //when i run the program just get the first address and i wont print it all
City :soule
blood type : A+
please explain how can I use while loop in address
Edited by Roger, 06 March 2013 - 10:19 AM.
tags, formatting
















