Happy Codings - Programming Code Examples
Html Css Web Design Sample Codes CPlusPlus Programming Sample Codes JavaScript Programming Sample Codes C Programming Sample Codes CSharp Programming Sample Codes Java Programming Sample Codes Php Programming Sample Codes Visual Basic Programming Sample Codes


Java Programming Code Examples

Java > Swing Code Examples

Exam Analysis Programme Using JOptionPane

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
Exam Analysis Programme Using JOptionPane import javax.swing.JOptionPane; public class ExamAnalysis { public static void main( String args[] ) { // initializing variables in declarations int passes = 0, // number of passes failures = 0, // number of failures student = 1, // student counter result; // one exam result String input, // user-entered value output; // output string // process 10 students; counter-controlled loop while ( student <= 10 ) { input = JOptionPane.showInputDialog( "Enter result (1=pass,2=fail)" ); result = Integer.parseInt( input ); if ( result == 1 ) passes = passes + 1; else failures = failures + 1; student = student + 1; } // termination phase output = "Passed: " + passes + "\nFailed: " + failures; if( passes > 8 ) output = output + "\nRaise Tuition"; JOptionPane.showMessageDialog( null, output, "Analysis of Examination Results", JOptionPane.INFORMATION_MESSAGE ); System.exit( 0 ); } }