Creating an Array

From CompSciWiki
Revision as of 12:13, 1 April 2010 by JustinS (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Back to the Program-A-Day homepage

Problem

There are ten students with ten grades. Instead of storing every single grade in a single variable it is easier to store this information in an array. Given that the grades are 56%, 34%, 75%, 89%, 78%, 87%, 71%, 67%, 98%, 85%, store the grades in an integer array as percents and convert them to decimals and store them in a double array.

 

SideSectionTitle

float
Taken from http://www.flickr.com/photos/daniello/565304023/

An image or By Students section

Solution

public class Creating{

 public static void main(String[] args){
   int[] intArray = {56, 34, 75, 89, 78, 87, 71, 67, 98, 85};
   double[] decimalArray = {0.56, 0.34, 0.75, 0.89, 0.78, 0.87, 0.71, 0.67, 0.98, 0.85};
 }

}

Code

SolutionCode goes here. Please DO NOT put your code in <pre> tags!

Back to the Program-A-Day homepage