HW05 Solution1

HW05 Solution1 - d = d + 1 else f = f + 1...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 // Solution to Homework #5, Problem #1 public class HW5_1 { public static void main(String[] args) { int[] grades = {90, 60, 85, 73, 88, 92, 100} // Basic solution int a = 0 // Number of A's int b = 0 // Number of B's int c = 0 // Number of C's int d = 0 // Number of D's int f = 0 // Number of F's for (int i = 0 i < grades.length i++) if (grades[i] >= 90) a = a + 1 else if (grades[i] >= 80) b = b + 1 else if (grades[i] >= 70) c = c + 1 else if (grades[i] >= 60)
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: d = d + 1 else f = f + 1 System.out.println(&quot;A's: &quot; + a) System.out.println(&quot;B's: &quot; + b) System.out.println(&quot;C's: &quot; + c) System.out.println(&quot;D's: &quot; + d) System.out.println(&quot;F's: &quot; + f) // // Advdanced solution // int counts = new int[ // for (int i = 0 i &lt; grades.length i++) // if (grades[i] &lt; 60) // counts[0]++ // else { // int modifiedGrade = (int) ((grades[i] - 50) / 10.0) // // System.out.println(&quot;A's: &quot; + a) } }...
View Full Document

This note was uploaded on 04/10/2008 for the course ENGR 131 taught by Professor Xiaowei during the Spring '07 term at Case Western.

Ask a homework question - tutors are online