Copyright  © – Sudharsan Iyengar and Winona State University

 

CS – 234.                                Lab 7                                       10/23/24

 

Part A:

 

Write an application that uses a scanner and reads from a file input7.txt

 

a)               The first line has a long integer.

 

The first large number is : 84243574238234899274827492849.

 

b)               The second line has another long integer.

 

The second large number is : 979751308959079072349579739245797.

 

Your application should add and display their sum.

 

c)               Display the sum of the two long numbers.

 

 

Ex: File contains:

            84243574238234899274827492849

            979751308959079072349579739245797

 

 

                        Output:

                    84243574238234899274827492849

            979751308959079072349579739245797

Sum = 979835552533317307248854566738646

 

Part B:

 

Write a class longnum that has a name (String) and a long number (String). It should have a constructor, getName(); and a ADD method that takes in two long numbers and returns the sum of the two long numbers (as in part A). Write an application longnumApp that reads an input file input7B.txt that contains 10 long numbers – each line has one name followed by one long number as follows

 

            First 9897435927924359779423598

 

Create and store the ten (10) long numbers in an array of longnum; create a menu to select two long numbers and display the sum of the two long numbers.