Posted by: Chyne on: May 23, 2009
/* Exercise 7.13
* 1. Use enhanced for statement
* 2. Sum the double values passed by the command-line arguments.
* 3. Use the static method parseDouble of class Double to convert a String to a double value.
*/
package Exercises;
public class SumDouble {
public static void main(String []args)
{
// get array size from first command-line-argument
int arrayLength = Integer.parseInt(args[0]);
int array[] = new int[arrayLength]; // create array
// get initial value and increment from command-line argument
double initialValue = Double.parseDouble(args[1]);
double increment = Double.parseDouble(args[2]);
// sum the double values passed by the command-line arguments
for(int counter:array)
initialValue+=increment;
System.out.println(initialValue);
} // end main
} // end class SumDouble
September 14, 2009 at 6:32 am
Hi, your codes have been so helpful with my course work and I am just wondering if you have any additional codes for the remaining chapter 7 arrays.
I am truly struggling with this at this point and would be so happy if you would post some more.
Thanks in advance.
Keith
PS if you have more available I would appreciate it so much if you could email them to his_anointed@live.com as well.