Question
can someone please help me with this program? I am having a hard time with it and it is super frustrating. Program so far: //
can someone please help me with this program? I am having a hard time with it and it is super frustrating. Program so far: // This program reads an input file that contains sequences of integers to // be added together. The program reads them as Strings so that it can // process large integers. Reset the constant DIGITS to allow it to handle // larger integers. import java.io.*; import java.util.*; public class SumShell { public static final int DIGITS = 25; public static void main(String[] args) throws FileNotFoundException { Scanner input = new Scanner(new File("sum.txt")); processFile(input); } //this method calls the method processLine public static void processFile(Scanner input) { int lines = 0; while (input.hasNextLine()) { } System.out.println(); System.out.println("Total lines = " + lines); } //declare an array for the result of some public static void processLine(Scanner data) { int[] result = new int[DIGITS]; String next = data.next(); transfer(next, result); System.out.print(next); while (data.hasNext()) { int[] number = new int[DIGITS]; //read the next token //declare ann array to convert the token that was read into that array //call the method transfer //call the method addto transfer(next, number); addTo(result, number); System.out.print(" + " + next); } System.out.print(" = "); print(result); System.out.println(); } //transfer the string to the array digits public static void transfer(String data, int[] digits) { } // add the array number to the array sum public static void addTo(int[] sum, int[] number) { int carry = 0; for (int i = DIGITS - 1; i >= 0; i--) { } if (carry > 0) throw new RuntimeException("overflow"); } //output the content of the array digits public static void print(int[] digits) { int start = 0; } }
Input file sum.txt
82384
204 435 22 31 12
999 483
28350 28345 39823 95689 234856 3482 55328 934803
7849323789 22398496 8940 32489 859320
729348690234239 542890432323 534322343298
3948692348692348693486235 5834938349234856234863423
999999999999999999999999 432432 58903 34
82934 49802390432 8554389 4789432789 0 48372934287
0
0 0 0
7482343 0 4879023 0 8943242
3333333333 4723 3333333333 6642 3333333333
Output that should be produced
82384 = 82384 204 + 435 = 639
22 + 31 + 12 = 65 999 + 483 = 1482
28350 + 28345 + 39823 + 95689 + 234856 + 3482 + 55328 + 934803 = 1420676
7849323789 + 22398496 + 8940 + 32489 + 859320 = 7872623034
729348690234239 + 542890432323 + 534322343298 = 730425903009860
3948692348692348693486235 + 5834938349234856234863423 = 9783630697927204928349658 999999999999999999999999 + 432432 + 58903 + 34 = 1000000000000000000491368
82934 + 49802390432 + 8554389 + 4789432789 + 0 + 48372934287 = 102973394831
0 = 0
0 + 0 + 0 = 0
7482343 + 0 + 4879023 + 0 + 8943242 = 21304608
3333333333 + 4723 + 3333333333 + 6642 + 3333333333 = 10000011364
Total lines = 14
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started