/** * * @author: Huma UmmulBanin Zaidi * @Project:Project1, Data Structure. * Running program looks like: This program finds sum or product of a LARGE numbers of integers. Enter as many integers > 0 as you would like. Enter the numbers: 1 3 5 7 7 5 3 1 Please select the number of one of these options: 1. Sum the numbers in the list 2. Multiply the numbers in the list Your choice: 1 Answer is: 16 Exiting program... */
public class Project1 { //public class ReadFile { // Read lists of numbers from a specified text file. public static void main(String[] args){
if(args.length == 0) System.out.println("No file specified."); else { FileReader theFile; BufferedReader inFile; String oneLine; int s; try{ // file not found exception must be caught theFile = new FileReader(args[0]); inFile = new BufferedReader(theFile); while((oneLine = inFile.readLine()) != null) { String numbers[] = oneLine.split(","); // " " for space s = 0; for (int i=0; i<numbers.length; i++) s=s+Integer.parseInt(numbers[i]); System.out.println(numbers.length + "numbers Processed. There Sum equals" +s+ "."); } //end while } // else catch (Exception e) {System.out.println(e); } System.out.println("Test"); BigDecimal n1 = new BigDecimal("123"); System.out.println(n1); BigDecimal n2 = new BigDecimal ("345"); LargeNumbers a = new LargeNumbers(n1); LargeNumbers b = new LargeNumbers(n2); System.out.println(a.toString()); System.out.println(b.toString()); LargeNumbers.AddNumbers (a,b);