+ Link For Assignments, GDBs & Online Quizzes Solution |
+ Link For Past Papers, Solved MCQs, Short Notes & More |
Tags:
+ http://bit.ly/vucodes (Link for Assignments, GDBs & Online Quizzes Solution)
+ http://bit.ly/papersvu (Link for Past Papers, Solved MCQs, Short Notes & More)
+ Click Here to Search (Looking For something at vustudents.ning.com?) + Click Here To Join (Our facebook study Group)any one help me error on gui can,t display any thing
agar hm cmd ki bjae netbean me assignment bna k submit kren to kia galt ho gi plz tell me any one?
plz koi btae kia cmd me hi run krna zaroori h is ka b to apna cmd h
yes
bhai average calculte ka code dy do..
yes
first of all you have to make a class in notepad with the name "Student.java"
code is shown below
public static class Student{
//if there is problem while compling of static keyword remove the static word from above //line and compile and run it again
private String name;
private String roll;
private String marks;
//default constructor
public Student(){
name=null;
roll=null;
marks=null;
}
//userdefined structor
public Student(String Name,String Rollno, String Marks){
this.name=Name;
this.roll=Rollno;
this.marks=Marks;
}
public String getName(){
return name;
}
public void setName(String name){
this.name=name;
}
public String getRoll(){
return roll;
}
public void setRoll(String Roll_no){
this.roll=Roll_no;
}
public String getMarks(){
return marks;
}
public void setMarks(String Marks){
this.marks=Marks;
}
//end of student class
now you have to make a class named "Test.java"
public class Test {
public static void main(String[] args) {
JFrame myFrame = new JFrame();
GridLayout layout = new GridLayout(0,3);
myFrame.setLayout(layout);
ArrayList<Student> list= new ArrayList<Student>();
myFrame.add(new JLabel("Name"));
myFrame.add(new JLabel("Roll No"));
myFrame.add(new JLabel("Marks"));
String words[]= null;
String name, rollNo,marks;
// int total=0;
try{
FileReader fr= new FileReader("input.txt");
BufferedReader br= new BufferedReader(fr);
String line= br.readLine();
while(line!= null){
words = line.split(" ");
name=words[0];
rollNo=words[1];
marks=words[2];
Student student = new Student(name,rollNo,marks);
list.add(student);
line =br.readLine();
System.out.println("Name: "+student.getName()+" Roll No: "+student.getRoll()+" Marks: "+student.getMarks());
myFrame.add(new JLabel (student.getName()));
myFrame.add(new JLabel (student.getRoll()));
myFrame.add(new JLabel (student.getMarks()));
}
myFrame.setSize(400, 200);
myFrame.setVisible(true);
myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
br.close();
fr.close();
}catch(Exception e){
System.out.println("File Not Found");
}
}
//end of Test File
make a folder then have these two files in it
then compile it but before compling make an "input.txt" file in same folder
input.txt file should look like this
Ali 1 70
Ahmad 2 60
Ayesha 3 80
Hina 4 90
Sana 5 50
you can copy these above values and paste it in notepad and save it as input.txt
but one thing i leave for you that you should have to make average of students by own self i remove that code...........
:) if there any problem can mail me at mc130400939@vu.edu.pk
this is code doesn't work ,error show
sir kia yah solution theek hn
reached end of file while parsing................error hy
o bhai Average calculate ka he code cahey bs...
© 2021 Created by + M.Tariq Malik.
Powered by
Promote Us | Report an Issue | Privacy Policy | Terms of Service
We have been working very hard since 2009 to facilitate in learning Read More. We can't keep up without your support. Donate.
We are user-generated contents site. All product, videos, pictures & others contents on site don't seem to be beneath our Copyrights & belong to their respected owners & freely available on public domains. We believe in Our Policy & do according to them. If Any content is offensive in your Copyrights then please email at m.tariqmalik@gmail.com Page with copyright detail & We will happy to remove it immediately.
Management: Admins ::: Moderators
Awards Badges List | Moderators Group
All Members | Featured Members | Top Reputation Members | Angels Members | Intellectual Members | Criteria for Selection
Become a Team Member | Safety Guidelines for New | Site FAQ & Rules | Safety Matters | Online Safety | Rules For Blog Post