This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Bonfire: Return Largest Numbers in Arrays | |
// Author: @gulzaar | |
// Challenge: http://www.freecodecamp.com/challenges/bonfire-return-largest-numbers-in-arrays | |
// Learn to Code at Free Code Camp (www.freecodecamp.com) | |
function largestOfFour(arr) { | |
// You can do this! | |
var mNum = new Array(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Fig. 7.6: BarChart.java | |
// Bar chart printing program. | |
public class BarChart { | |
public static void main( String[] args ) { | |
int[] array = { 0, 0, 0, 0, 0, 0, 1, 2, 4, 2, 1 }; | |
System.out.println( "Grade distribution:" ); | |
// for each array element, output a bar of the chart |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Fig. 7.8: StudentPoll.java | |
// Poll analysis program. | |
public class StudentPoll { | |
public static void main( String[] args ) { | |
// student response array (more typically, input at runtime) | |
int[] responses = { 1, 2, 5, 4, 3, 5, 2, 1, 3, 3, 1, 4, 3, 3, 3, 2, 3, 3, 2, 14 }; | |
int[] frequency = new int[ 6 ]; // array of frequency counters | |
// for each answer, select responses element and use that value | |
// as frequency index to determine element to increment |