۱۳۸۷ مهر ۲, سه‌شنبه

نرم افزار محاسبه معدلComputing Avarage

این برنامه ابتدا تعداد کل دانش آموزان را گرفته. سپس نمره ها را دریافت میکند و علاوه بر نمایش معدل کل کلاس تعداد دانش آموزان کمتر از 10 بین 10تا 15 و بالاتر از 15 را اعلام میکند! به علاوه ماکزیمم . مینیمم کلاس را هم اعلام میکند. این برنامه توسط لاگ لینوکس اصفهان گروه جاوا نوشته شده است

This program takes number of all students firstly, then takes all grades of the students in your class then will give you average of class also the grades less than 10 -between 10-15 and more than 15, the highest grade in this program is 20 as Iranian schools, also it shows you maximum and minimum grades.
enjoy it

import javax.swing.JOptionPane;

import java.lang.Double;




/**
*
* @author kimi
*/
public class NewJFrame extends javax.swing.JFrame {

/** Creates new form NewJFrame */
public NewJFrame() {
initComponents();

}

/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
//
private void initComponents() {

jButton1 = new javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

jButton1.setText("????");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(170, 170, 170)
.addComponent(jButton1)
.addContainerGap(169, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(216, Short.MAX_VALUE)
.addComponent(jButton1)
.addGap(61, 61, 61))
);

pack();
}//


private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
int gradeCounter,counter1,counter2,counter3, A;

Double gradeValue, average;

Double total = 0.00;
Double min = 20.00;
Double max =0.00;



String grade = "";

String Allstudents;



gradeCounter = 1;

counter1 = 0;

counter2 = 0;

counter3 = 0;

Allstudents = JOptionPane.showInputDialog(

"Enter Number Of All Students");



A = Integer.parseInt(Allstudents); // convert Allstudents from a string to an integer



while (gradeCounter <= A) //loop A times { grade = JOptionPane.showInputDialog("Enter Grade"); gradeValue =Double.parseDouble(grade);// convert grade from a string to a Double total = total + gradeValue; if (gradeValue < counter1 =" counter1">= 10 && gradeValue <= 15) counter2 = counter2 +1; if (gradeValue > 15 )

counter3 = counter3 +1;
if (gradeValue < min =" gradeValue;"> max)
max = gradeValue;

gradeCounter = gradeCounter + 1;

}



average = total / A;







JOptionPane.showMessageDialog(null, "Class average is: " + average +

"\n"+

"\n Less than 10 : " + counter1 +

"\n Between 10 and 15 : " + counter2 +

"\n More than 15 : " + counter3 +
"\n" +
"\n Maximum Grade : " + max +
"\n Minimum Grade : " + min +
"\n" +
"\n Authors : Isfahan Linux User Group" +
"\n http://www.isfahanlug.org/smf/index.php?board=6.0",


"Class Average",

JOptionPane.INFORMATION_MESSAGE);

System.exit(0);






}

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new NewJFrame().setVisible(true);
}
});
}

// Variables declaration - do not modify
private javax.swing.JButton jButton1;
// End of variables declaration

}

0

هیچ نظری موجود نیست: