2630006 Programming Skills IV Java (As per New Syllabus - July 2013) - Download
1. Program 1
2. Program 2
3. Program 3
4. Program 4
5. Program 5
6. Program 6
7. Program 7
8. Program 8
9. Program 9
10. Program 10
11. Program 11
12. Program 12
13. Program 13
14. Program 14
15. Program 15
16. Program 16
17. Program 17
18. Program 18
19. Program 19
/*
Program 1:
=========
Write a JAVA program which performs the following listed operations:
A. Create a package named MyPackage which consists of following classes
1. A class named Student which stores information like the roll number, first name, middle name, last name, address and age of the student. The class should also contain appropriate get and set methods.
2. A class named AddStudentFrame which displays a frame consisting of appropriate controls to enter the details of a student and store these details in the Student class object. The frame should also have two buttons with the caption as “Add Record” and “Search Record”.
3. A class named MyCustomListener which should work as a user – defined event listener to handle required events as mentioned in following points.
B The “Add record” button should add the record entered in the frame controls to a pre – defined file.
C Provide a menu on the AddStudentFrame which has menu items titled, “Set the record file” and “Exit”.
1. When the “Set the record file” menu item is clicked, the user should be asked to input the complete path of the file where he desires to save the records.
2. When the “Exit” menu item is clicked, the frame should be closed.
[Note: Use the MyCustomListener class only to handle the appropriate events]
D 1. The “Search record” button should open a new frame which should take input of search criteria using a radio button. The radio button should provide facility to search on basis of first name, middle name or last name.
2. The new frame should also have a text box to input the search criteria value.
3. The search result should be displayed in a proper format on the same frame in a text area. [The records should be searched from the pre – defined file which consists all saved records]
[Note: Use the MyCustomListener class only to handle the appropriate events]
E Provide proper error messages and perform appropriate exceptions where ever required in all the classes
*/
File 1: Student.java (in MyPackage folder)
==========================================
package MyPackage;
import java.io.*;
public class Student
{
public int rollno;
public String fname;
public String mname;
public String lname;
public Student()
{
}
Student(int rollno,String fname,String mname,String lname)
{
this.rollno=rollno;
this.fname=fname;
this.mname=mname;
this.lname=lname;
}
public void setData(int rollno,String fname,String mname,String lname)
{
this.rollno=rollno;
this.fname=fname;
this.mname=mname;
this.lname=lname;
}
public String getData()
{
String s = "Roll No : "+rollno + ", First Name : " + fname+ ", Middle Name : " + mname+ ", Last Name : " + lname;
return s;
}
}
File 2: AddStudentFrame.java (outside MyPackage folder)
=======================================================
import MyPackage.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
public class AddStudentFrame extends Frame
{
Button add;
Button search;
Label l1,l2,l3,l4;
TextField tfrollno;
TextField tffname;
TextField tfmname;
TextField tflname;
Label lblnotification;
MenuBar menubar;
MyCustomListener nl = new MyCustomListener();
AddStudentFrame()
{
setLayout(new FlowLayout());
setSize(300,300);
setVisible(true);
l1 = new Label("Roll No. : ");
l2 = new Label("First Name : ");
l3 = new Label("Middle Name : ");
l4 = new Label("Last Name : ");
tfrollno = new TextField(20);
tffname = new TextField(20);
tfmname = new TextField(20);
tflname = new TextField(20);
tfrollno.setName("tfrollno");
tffname.setName("tffname");
tfmname.setName("tfmname");
tflname.setName("tflname");
tfrollno.addTextListener(nl);
tffname.addTextListener(nl);
tfmname.addTextListener(nl);
tflname.addTextListener(nl);
add = new Button("Add Student");
search = new Button("Search Student");
lblnotification = new Label();
add.addActionListener(nl);
search.addActionListener(nl);
addWindowListener(nl);
add(l1);
add(tfrollno);
add(l2);
add(tffname);
add(l3);
add(tfmname);
add(l4);
add(tflname);
add(add);
add(search);
add(lblnotification);
menubar = new MenuBar();
Menu file = new Menu("Menu",true);
MenuItem item1,item2;
item1 = new MenuItem("Set the record file");
file.add(item1);
item2 = new MenuItem("Exit");
file.add(item2);
item1.addActionListener(nl);
item2.addActionListener(nl);
menubar.add(file);
setMenuBar(menubar);
}
}
File 3: NewFrame.java (outside MyPackage folder)
================================================
import MyPackage.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
public class NewFrame extends Frame
{
Button display;
TextField tfnm;
TextArea tadetail;
Checkbox cb1,cb2,cb3;
CheckboxGroup cg;
MyCustomListener nl2 = new MyCustomListener(tadetail);
public NewFrame()
{
try
{
setLayout(new FlowLayout());
setSize(500,400);
setVisible(true);
display=new Button("Display");
tfnm = new TextField(20);
tfnm.setName("tfnm");
tadetail = new TextArea();
nl2 = new MyCustomListener(tadetail);
cg = new CheckboxGroup();
cb1 = new Checkbox("First Name",true,cg);
cb2 = new Checkbox("Middle Name",false,cg);
cb3 = new Checkbox("Last Name",false,cg);
cb1.setName("First Name");
cb2.setName("Middle Name");
cb3.setName("Last Name");
tfnm.addTextListener(nl2);
cb1.addItemListener(nl2);
cb2.addItemListener(nl2);
cb3.addItemListener(nl2);
display.addActionListener(nl2);
add(cb1);
add(cb2);
add(cb3);
add(tfnm);
add(display);
add(tadetail);
addWindowListener(nl2);
}
catch(Exception e)
{
System.out.println(e);
}
}
}
File 4: MyCustomListener.java (outside MyPackage folder)
========================================================
import MyPackage.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
public class MyCustomListener extends WindowAdapter implements TextListener, ActionListener, ItemListener
{
Student st = new Student();
static String filename="a.txt";
int cbstatus=1;
String searchname="";
TextArea t;
public MyCustomListener(){}
public MyCustomListener(TextArea t)
{
this.t=t;
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getActionCommand().equals("Add Student"))
{
try
{
FileOutputStream fos = new FileOutputStream(filename,true);
PrintStream p = new PrintStream(fos);
p.println(st.rollno+","+st.fname+","+st.mname+","+st.lname);
fos.close();
p.close();
JOptionPane.showMessageDialog(null,"Record Added in File","Message",JOptionPane.INFORMATION_MESSAGE);
}
catch(IOException e)
{
System.out.println("Error - "+e);
}
}
else if(ae.getActionCommand().equals("Search Student"))
{
new NewFrame();
}
else if(ae.getActionCommand().equals("Display"))
{
try
{
String str;
String sarr[];
FileReader fis = new FileReader(filename);
BufferedReader br = new BufferedReader(fis);
boolean flag = false;
while((str = br.readLine())!= null)
{
//System.out.println(str);
sarr = str.split(",");
String temp="";
if(cbstatus==1)
temp=sarr[1];
else if(cbstatus==2)
temp=sarr[2];
else if(cbstatus==3)
temp=sarr[3];
if(temp.equals(searchname))
{
String msg = "Student Roll No : "+sarr[0]+" \nFirst Name : "+sarr[1]+" \nMiddle Name : "+sarr[2]+" \nLast Name : "+sarr[3]+"\n\n";
//JOptionPane.showMessageDialog(null,msg,"Message",JOptionPane.INFORMATION_MESSAGE);
t.setText(msg);
flag = true;
break;
}
}
fis.close();
br.close();
if(flag==false)
JOptionPane.showMessageDialog(null,"Record not found for given detail","Message",JOptionPane.INFORMATION_MESSAGE);
}
catch(IOException e)
{
System.out.println("Error - " +e);
e.printStackTrace();
}
}
else if(ae.getActionCommand().equals("Set the record file"))
{
Frame ff = new Frame();
FileDialog fd = new FileDialog(ff,"Choose a file", FileDialog.LOAD);
fd.setDirectory("C:\\");
fd.setFile("*.txt");
fd.setVisible(true);
filename = fd.getDirectory()+"\\"+fd.getFile();
}
else if(ae.getActionCommand().equals("Exit"))
{
System.exit(0);
}
}
public void textValueChanged(TextEvent e)
{
TextField tf = (TextField)e.getSource();
if(tf.getName().equals("tfrollno"))
st.rollno = Integer.parseInt(tf.getText());
else if(tf.getName().equals("tffname"))
st.fname = tf.getText();
else if(tf.getName().equals("tfmname"))
st.mname = tf.getText();
else if(tf.getName().equals("tflname"))
st.lname = tf.getText();
else if(tf.getName().equals("tfnm"))
searchname=tf.getText();
}
public void itemStateChanged(ItemEvent e)
{
Checkbox cb = (Checkbox)e.getSource();
if(cb.getName().equals("First Name"))
{
cbstatus=1;
}
else if(cb.getName().equals("Middle Name"))
{
cbstatus=2;
}
else if(cb.getName().equals("Last Name"))
{
cbstatus=3;
}
}
public void windowClosing(WindowEvent ae)
{
System.exit(0);
}
}
File 5: test.java (outside MyPackage folder)
================================================
import java.awt.*;
public class test
{
public static void main(String args[])
{
AddStudentFrame f = new AddStudentFrame();
}
}
Shared By : Prof. Milan Vachhani, MCA Dept., B. H. Gardi
Show/Hide Program
/*
Program 1:
=========
Write a JAVA program which performs the following listed operations:
A. Create a package named MyPackage which consists of following classes
1. A class named Student which stores information like the roll number, first name, middle name, last name, address and age of the student. The class should also contain appropriate get and set methods.
2. A class named AddStudentFrame which displays a frame consisting of appropriate controls to enter the details of a student and store these details in the Student class object. The frame should also have two buttons with the caption as “Add Record” and “Search Record”.
3. A class named MyCustomListener which should work as a user – defined event listener to handle required events as mentioned in following points.
B The “Add record” button should add the record entered in the frame controls to a pre – defined file.
C Provide a menu on the AddStudentFrame which has menu items titled, “Set the record file” and “Exit”.
1. When the “Set the record file” menu item is clicked, the user should be asked to input the complete path of the file where he desires to save the records.
2. When the “Exit” menu item is clicked, the frame should be closed.
[Note: Use the MyCustomListener class only to handle the appropriate events]
D 1. The “Search record” button should open a new frame which should take input of search criteria using a radio button. The radio button should provide facility to search on basis of first name, middle name or last name.
2. The new frame should also have a text box to input the search criteria value.
3. The search result should be displayed in a proper format on the same frame in a text area. [The records should be searched from the pre – defined file which consists all saved records]
[Note: Use the MyCustomListener class only to handle the appropriate events]
E Provide proper error messages and perform appropriate exceptions where ever required in all the classes
*/
File 1: Student.java (in MyPackage folder)
==========================================
package MyPackage;
import java.io.*;
public class Student implements Serializable
{
public int rollno;
public String fname;
public String mname;
public String lname;
public Student()
{
}
Student(int rollno,String fname,String mname,String lname)
{
this.rollno=rollno;
this.fname=fname;
this.mname=mname;
this.lname=lname;
}
public void setData(int rollno,String fname,String mname,String lname)
{
this.rollno=rollno;
this.fname=fname;
this.mname=mname;
this.lname=lname;
}
public String getData()
{
String s = "Roll No : "+rollno + ", First Name : " + fname+ ", Middle Name : " + mname+ ", Last Name : " + lname;
return s;
}
}
File 2: test.java (outside MyPackage folder)
==========================================
import MyPackage.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
class AddStudentFrame extends Frame
{
Button add;
Button search;
Label l1,l2,l3,l4;
TextField tfrollno;
TextField tffname;
TextField tfmname;
TextField tflname;
Label lblnotification;
MenuBar menubar;
String filename="a.txt";
Button display;
TextField tfnm;
TextArea tadetail;
Checkbox cb1,cb2,cb3;
CheckboxGroup cg;
AddStudentFrame()
{
setLayout(new FlowLayout());
setSize(300,300);
setVisible(true);
l1 = new Label("Roll No. : ");
l2 = new Label("First Name : ");
l3 = new Label("Middle Name : ");
l4 = new Label("Last Name : ");
tfrollno = new TextField(20);
tffname = new TextField(20);
tfmname = new TextField(20);
tflname = new TextField(20);
add = new Button("Add Student");
search = new Button("Search Student");
lblnotification = new Label();
add.addActionListener(new MyCustomListner());
search.addActionListener(new MyCustomListner());
addWindowListener(new closewindow());
add(l1);
add(tfrollno);
add(l2);
add(tffname);
add(l3);
add(tfmname);
add(l4);
add(tflname);
add(add);
add(search);
add(lblnotification);
menubar = new MenuBar();
Menu file = new Menu("Menu",true);
MenuItem item1,item2;
item1 = new MenuItem("Set the record file");
file.add(item1);
item2 = new MenuItem("Exit");
file.add(item2);
item1.addActionListener(new MyCustomListner());
item2.addActionListener(new MyCustomListner());
menubar.add(file);
setMenuBar(menubar);
}
class MyCustomListner implements ActionListener
{
public void actionPerformed(ActionEvent ae)
{
//System.out.println("You have clicked on "+ae.getActionCommand());
if(ae.getActionCommand().equals("Add Student"))
{
Student st = new Student();
st.setData(Integer.parseInt(tfrollno.getText()),tffname.getText(),tfmname.getText(),tflname.getText());
try
{
FileOutputStream fos = new FileOutputStream(filename,true);
PrintStream p = new PrintStream(fos);
p.println(st.rollno+","+st.fname+","+st.mname+","+st.lname);
fos.close();
p.close();
lblnotification.setText("Record Added in File");
}
catch(IOException e)
{
System.out.println("Error - "+e);
}
}
else if(ae.getActionCommand().equals("Search Student"))
{
try
{
Frame newframe = new Frame();
newframe.setLayout(new FlowLayout());
newframe.setSize(500,400);
newframe.setVisible(true);
display=new Button("Display");
tfnm = new TextField(20);
tadetail = new TextArea();
cg = new CheckboxGroup();
cb1 = new Checkbox("First Name",true,cg);
cb2 = new Checkbox("Middle Name",false,cg);
cb3 = new Checkbox("Last Name",false,cg);
display.addActionListener(this);
newframe.add(cb1);
newframe.add(cb2);
newframe.add(cb3);
newframe.add(tfnm);
newframe.add(display);
newframe.add(tadetail);
newframe.addWindowListener(new closewindow());
}
catch(Exception e)
{
System.out.println("Error - "+e);
}
}
else if(ae.getActionCommand().equals("Display"))
{
try
{
String str;
String sarr[];
FileReader fis = new FileReader(filename);
BufferedReader br = new BufferedReader(fis);
boolean flag = false;
while((str = br.readLine())!= null)
{
sarr = str.split(",");
String temp="";
if(cb1.getState())
temp=sarr[1];
else if(cb2.getState())
temp=sarr[2];
else if(cb3.getState())
temp=sarr[3];
if(temp.equals(tfnm.getText()))
{
tadetail.setText("Student Roll No : "+sarr[0]+" \nFirst Name : "+sarr[1]+" \nMiddle Name : "+sarr[2]+" \nLast Name : "+sarr[3]+"\n\n");
flag = true;
break;
}
}
fis.close();
br.close();
if(flag==false)
tadetail.setText("Record not found for given detail");
}
catch(IOException e)
{
System.out.println("Error - " +e);
e.printStackTrace();
}
}
else if(ae.getActionCommand().equals("Set the record file"))
{
Frame ff = (Frame)menubar.getParent();
FileDialog fd = new FileDialog(ff,"Choose a file", FileDialog.LOAD);
fd.setDirectory("C:\\");
fd.setFile("*.txt");
fd.setVisible(true);
filename = fd.getDirectory()+"\\"+fd.getFile();
}
else if(ae.getActionCommand().equals("Exit"))
{
System.exit(0);
}
}
}
class closewindow extends WindowAdapter
{
public void windowClosing(WindowEvent ae)
{
System.exit(0);
}
}
}
public class test
{
public static void main(String args[])
{
AddStudentFrame f = new AddStudentFrame();
}
}
Shared By : 333
Show/Hide Program
Program 1 solution 3
2. Program 2
Shared By : 111
Show/Hide Program
Program 2 Solution
Shared By : 222
Show/Hide Program
Program 2 solution 2
Shared By : 333
Show/Hide Program
Program 2 solution 3
3. Program 3
Shared By : 111
Show/Hide Program
Program 3 Solution
Shared By : 222
Show/Hide Program
Program 3 solution 2
Shared By : 333
Show/Hide Program
Program 3 solution 3
4. Program 4
Shared By : 111
Show/Hide Program
Program 4 Solution
Shared By : 222
Show/Hide Program
Program 4 solution 2
Shared By : 333
Show/Hide Program
Program 4 solution 3
5. Program 5
Shared By : 111
Show/Hide Program
Program 5 Solution
Shared By : 222
Show/Hide Program
Program 5 solution 2
Shared By : 333
Show/Hide Program
Program 5 solution 3
6. Program 6
Shared By : 111
Show/Hide Program
Program 6 Solution
Shared By : 222
Show/Hide Program
Program 2 solution 2
Shared By : 333
Show/Hide Program
Program 6 solution 3
7. Program 7
Shared By : Jethi Sagar, MCA Dept., B. H. Gardi
Show/Hide Program
File 1 : exam2.java (in javaappliation1 Folder)
===============================================
package javaapplication1;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
import java.io.*;
interface Exam {
boolean passExam(double ObtainedMarks, double totalmarks);
}
interface Classify {
String findDivision(double pre);
}
class studentdata implements Serializable
{
String Sname;
String Sexam;
float Ssub1;
float Ssub2;
float Ssub3;
float Ssub4;
float Ssub5;
float Stotal;
float Spre;
String Sdivision1;
studentdata(String xname, String xexam, float xsub1, float xsub2, float xsub3, float xsub4, float xsub5, float xtotal,String xdivision)
{
this.Sname = xname;
this.Sexam = xexam;
this.Ssub1 = xsub1;
this.Ssub2 = xsub2;
this.Ssub3 = xsub3;
this.Ssub4 = xsub4;
this.Ssub5 = xsub5;
this.Stotal = xtotal;
this.Sdivision1=xdivision;
}
void setdata(String s)
{
Sdivision1=s;
}
String printdata() {
String s = Sname + Sexam + String.valueOf(Ssub1) + String.valueOf(Ssub2) + String.valueOf(Ssub3) + String.valueOf(Ssub4) + String.valueOf(Ssub5) + String.valueOf(Stotal);
return s;
}
}
class Exam_result implements Exam, Classify,Serializable
{
public Exam_result()
{
}
@Override
public boolean passExam(double ObtainedMarks,double totalmarks) {
double f = (ObtainedMarks * 100) / totalmarks;
if (f >= 35) {
return true;
} else {
return false;
}
}
@Override
public String findDivision(double pre) {
if (pre >= 60) {
return "FIRST";
} else if (pre <= 60 && pre >= 50) {
return "SECOND";
} else {
return "NO DIVISION";
}
}
}
class AddExamFrame extends JFrame {
Container comp;
final JTextField namef, examf, sub1f, sub2f, sub3f, sub4f, sub5f, totalf;
final JLabel name, exam, sub1, sub2, sub3, sub4, sub5, total,notify1;
final JButton add1, viwe, find, exit;
String filename="a.txt";
JTextArea ViweData;
JPanel Right1;
AddExamFrame(String str) {
super(str);
///setLayout(new GridLayout(11, 2));
comp= getContentPane();
setLayout(new FlowLayout());
setSize(600,600);
setVisible(true);
this.setLocationRelativeTo ( null );
Right1=new JPanel();
Right1.setLayout(new GridLayout(11, 2));
name = new JLabel("Stdunt Name :");
namef = new JTextField(25);
exam = new JLabel("Exam Name :");
examf = new JTextField(20);
sub1 = new JLabel("Subject1 :");
sub1f = new JTextField(5);
sub2 = new JLabel("Subject2 :");
sub2f = new JTextField(5);
sub3 = new JLabel("Subject3 :");
sub3f = new JTextField(5);
sub4 = new JLabel("Subject4 :");
sub4f = new JTextField(5);
sub5 = new JLabel("Subject5 :");
sub5f = new JTextField(5);
total = new JLabel("Subject Total :");
totalf = new JTextField(5);
ViweData=new JTextArea(17,50);
ViweData.setEditable(false);
add1 = new JButton("Add Marks");
find = new JButton("Find Division");
viwe = new JButton("View Result");
exit = new JButton("Exit");
notify1=new JLabel( );
Right1.add(name);
Right1.add(namef);
Right1.add(exam);
Right1.add(examf);
Right1.add(sub1);
Right1.add(sub1f);
Right1.add(sub2);
Right1.add(sub2f);
Right1.add(sub3);
Right1.add(sub3f);
Right1.add(sub4);
Right1.add(sub4f);
Right1.add(sub5);
Right1.add(sub5f);
Right1.add(total);
Right1.add(totalf);
Right1.add(add1);
Right1.add(viwe);
Right1.add(find);
Right1.add(exit);
Right1.add(notify1);
this.add(Right1);
add(ViweData);
ViweData.setEditable ( false ); // set textArea non-editable
JScrollPane scroll = new JScrollPane (ViweData );
scroll.setVerticalScrollBarPolicy ( ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS );
//Add Textarea in to middle panel
add ( scroll );
class MyCustomListner implements ActionListener
{
public void actionPerformed(ActionEvent ae)
{
if (ae.getActionCommand().equals("Add Marks"))
{
studentdata st = new studentdata(namef.getText(), examf.getText(),Float.parseFloat(sub1f.getText()), Float.parseFloat(sub2f.getText()),Float.parseFloat(sub3f.getText()),Float.parseFloat(sub4f.getText()),Float.parseFloat(sub5f.getText()),Float.parseFloat(totalf.getText()),null);
try {
FileWriter fos = new FileWriter(filename, true);
BufferedWriter p1 = new BufferedWriter(fos);
p1.write(st.Sname + "," + st.Sexam + "," + st.Ssub1 + "," + st.Ssub2 + "," + st.Ssub3 + "," + st.Ssub4 + "," + st.Ssub5 + "," + st.Stotal+"\n");
p1.flush();
p1.close();
fos.close();
JOptionPane.showMessageDialog(null,"Add Record Succefully","ADD RECORD", JOptionPane.INFORMATION_MESSAGE);
}
catch (IOException e)
{
System.out.println("Error - " + e);
}
}
else if (ae.getActionCommand().equals("Find Division"))
{
Exam_result examR=new Exam_result();
try {
studentdata st1 = new studentdata(namef.getText(), examf.getText(),Float.parseFloat(sub1f.getText()), Float.parseFloat(sub2f.getText()),Float.parseFloat(sub3f.getText()),Float.parseFloat(sub4f.getText()),Float.parseFloat(sub5f.getText()),Float.parseFloat(totalf.getText()),null);
float sum =st1.Ssub1 +st1.Ssub2+st1.Ssub3 +st1.Ssub4 +st1.Ssub5;
double p=(sum/st1.Stotal)*100;
String msg =examR.findDivision(p) ;
JOptionPane.showMessageDialog(null," Your Division is:"+msg,"Result", JOptionPane.INFORMATION_MESSAGE);
try {
FileWriter fos = new FileWriter("d.txt", true);
BufferedWriter p1 = new BufferedWriter(fos);
st1.setdata(msg);
p1.write(st1.Sname + "," + st1.Sdivision1+"\n");
fos.close();
p1.close();
// notify1.setText("Record Added in File");
}
catch (Exception e)
{
System.out.println("Error - " + e);
}
} catch (Exception e) {
System.out.println("Error - " + e);
}
}
else if (ae.getActionCommand().equals("View Result"))
{
try {
String str;
// String sarr[];
FileReader fis = new FileReader("a.txt");
BufferedReader br = new BufferedReader(fis);
boolean flag = false;
Font font1 = new Font("SansSerif", Font.BOLD,14);
ViweData.setFont(font1);
ViweData.setText("");
ViweData.setText(ViweData.getText()+"@@@@@@@-----------All Student Result----------@@@@@@@@@@"+"\n\n");
Exam_result examR1=new Exam_result();
while ((str = br.readLine()) != null || (str = br.readLine()) != "")
{
// JOptionPane.showMessageDialog(null," Your Division is:"+str,"Result", JOptionPane.INFORMATION_MESSAGE);
String sarr[] = str.split(",");
String temp = "";
// JOptionPane.showMessageDialog(null," Your Division is:"+sarr[0],"Result", JOptionPane.INFORMATION_MESSAGE);
double sum =Double.valueOf(Float.parseFloat(sarr[2]) +Float.parseFloat(sarr[3]) +Float.parseFloat(sarr[4])+Float.parseFloat(sarr[5])+Float.parseFloat(sarr[6]));
// JOptionPane.showMessageDialog(null," Your Division is:"+sum,"Result", JOptionPane.INFORMATION_MESSAGE);
// boolean Bresult = ;
String Sresult=examR1.passExam(sum,Double.parseDouble(sarr[7]))==true?"Pass":"Fail";
JOptionPane.showMessageDialog(null," Your Division is:"+Sresult,"Result", JOptionPane.INFORMATION_MESSAGE);
ViweData.setText(ViweData.getText()+" Student Name :"+sarr[0]+"\n"+" Exam Name :"+sarr[1]+"\n"+" Total Mark Obtained :"+String.valueOf(sum)+"\n"+" Result :"+Sresult);//+" "+sarr[1]+" "+sarr[2] + " "+"\n);
ViweData.setText(ViweData.getText()+"\n"+"======================================="+"\n");
}
fis.close();
br.close();
}
catch (IOException e)
{
System.out.println("Error - " + e);
e.printStackTrace();
}
} else if (ae.getActionCommand().equals("Set the record file")) {
// Frame ff = (Frame) menubar.getParent();
// FileDialog fd = new FileDialog(ff, "Choose a file", FileDialog.LOAD);
// fd.setDirectory("C:\\");
// fd.setFile("*.txt");
/// fd.setVisible(true);
// filename = fd.getDirectory() + "\\" + fd.getFile();
} else if (ae.getActionCommand().equals("Exit")) {
System.exit(0);
}
}
}
add1.addActionListener(new MyCustomListner());
find.addActionListener(new MyCustomListner());
viwe.addActionListener(new MyCustomListner());
exit.addActionListener(new MyCustomListner());
addWindowListener(new WindowAdapter() {
public void windoClosing(WindowEvent we) {
System.exit(0);
}
});
//comp.add(new Addpanel());
setVisible(true);
}
//add.addActionListener(new MyCustomListner());
//add.addActionListener(new MyCuStomListener());
}
class exam2 {
public static void main(String args[]) {
new AddExamFrame("Student");
}
}
Shared By : 222
Show/Hide Program
Program 7 solution 2
Shared By : 333
Show/Hide Program
Program 7 solution 3
8. Program 8
Shared By : 111
Show/Hide Program
Program 8 Solution
Shared By : 222
Show/Hide Program
Program 8 solution 2
Shared By : 333
Show/Hide Program
Program 8 solution 3
9. Program 9
Shared By : 111
Show/Hide Program
Program 9 Solution
Shared By : 222
Show/Hide Program
Program 9 solution 2
Shared By : 333
Show/Hide Program
Program 9 solution 3
10. Program 10
Shared By : 111
Show/Hide Program
Program 10 Solution
Shared By : 222
Show/Hide Program
Program 10 solution 2
Shared By : 333
Show/Hide Program
Program 10 solution 3
11. Program 11
Shared By : 111
Show/Hide Program
Program 11 Solution
Shared By : 222
Show/Hide Program
Program 11 solution 2
Shared By : 333
Show/Hide Program
Program 11 solution 3
12. Program 12
Shared By : 111
Show/Hide Program
Program 12 Solution
Shared By : 222
Show/Hide Program
Program 12 solution 2
Shared By : 333
Show/Hide Program
Program 12 solution 3
13. Program 13
Shared By : 111
Show/Hide Program
Program 13 Solution
Shared By : 222
Show/Hide Program
Program 13 solution 2
Shared By : 333
Show/Hide Program
Program 13 solution 3
14. Program 14
Shared By : 111
Show/Hide Program
Program 14 Solution
Shared By : 222
Show/Hide Program
Program 14 solution 2
Shared By : 333
Show/Hide Program
Program 14 solution 3
15. Program 15
Shared By : 111
Show/Hide Program
Program 15 Solution
Shared By : 222
Show/Hide Program
Program 15 solution 2
Shared By : 333
Show/Hide Program
Program 15 solution 3
16. Program 16
Shared By : 111
Show/Hide Program
Program 16 Solution
Shared By : 222
Show/Hide Program
Program 16 solution 2
Shared By : 333
Show/Hide Program
Program 16 solution 3
17. Program 17
Shared By : 111
Show/Hide Program
Program 17 Solution
Shared By : 222
Show/Hide Program
Program 17 solution 2
Shared By : 333
Show/Hide Program
Program 17 solution 3
18. Program 18
Shared By : 111
Show/Hide Program
Program 18 Solution
Shared By : 222
Show/Hide Program
Program 18 solution 2
Shared By : 333
Show/Hide Program
Program 18 solution 3
19. Program 19
Shared By : 111
Show/Hide Program
Program 19 Solution
Shared By : 222
Show/Hide Program
Program 19 solution 2
Shared By : 333
Show/Hide Program
Program 19 solution 3
No comments:
Post a Comment