Answer to Question #2604 in Action Script | Flash | Flex | ColdFusion for kalai

Question #2604
the requirement:
The number of input integers (marks) should be at least 12 (meaning
counted 3 semester advanced standing from somewhere else) and at
most 30 including the failed mark and repeated mark of the same unit
(meaning you are automatically disqualified if you failed more than 6 units
during the course).

i have code following and i would like to know where to add arrays in this code?
import java.text.DecimalFormat;
import javax.swing.JOptionPane;
/**
*
* @author Acer
*/
public class Average2 {
public static void main( String args[] ) {
int gradeCounter, // number of grades entered
gradeValue, // grade value
total; // sum of grades
double average; // average of all grades
String input; // grade typed by user
// Initialization phase
total = 0; // clear total
gradeCounter = 0; // prepare to loop
// Processing phase
// prompt for input and read grade from user


input = JOptionPane.showInputDialog(
"Enter Integer Grade, -1 to Quit:" );
// convert grade from a String to an integer
gradeValue = Integer.parseInt( input );
while ( gradeValue != -1 ) {
// add gradeValue to total
total += gradeValue;
// add 1 to gradeCounter
gradeCounter += 1;

// prompt for input and read grade from user
input = JOptionPane.showInputDialog(
"Enter Integer Grade, -1 to Quit:" );
// convert grade from a String to an integer
gradeValue = Integer.parseInt( input );
}
// Termination phase
DecimalFormat twoDigits = new DecimalFormat( "0.00" );
if ( gradeCounter != 0) {
average = (double) total / gradeCounter;
// display average of exam grades
JOptionPane.showMessageDialog( null,
"Class average is " + twoDigits.format( average ),
"Class Average", JOptionPane.INFORMATION_MESSAGE );
}
else {
JOptionPane.showMessageDialog( null,
"No grades were entered", "Class Average",
JOptionPane.INFORMATION_MESSAGE );
}
}

} // end method main
// end class Average2
0
Expert's answer

Answer in progress...

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS