Respuesta :
Answer:
The output is seen bellow
Explanation:
public class BigInteger {
 public class Node{
   private char data;
   private Node next;
   public Node(char d){
     this.setData(d);
     this.setNext(null);
   }
   public char getData() {
     return data;
   }
   public void setData(char data) {
     this.data = data;
   }
   public Node getNext() {
     return next;
   }
   public void setNext(Node next) {
     this.next = next;
   }   Â
 }
Â
 private Node root;
Â
 public BigInteger(String s){
   this.root=null;
  Â
   for(int i=s.length()-1;i>=0;i--){
     Node node=new Node(s.charAt(i));
     node.setNext(root);
     root=node;
   }
 }
Â
 public String toString(){
   String str="";
   Node cur=this.root;
   int i=0;
  Â
   while(cur!=null){
     if(i==0 && cur.getData()=='0'){
      Â
     }
     else{
       i=1;
       str+=cur.getData();
     }
    Â
     cur=cur.getNext();
   }
  Â
   return str;
 }
Â
 public String reverse(String s){
   String ret="";   Â
   for(int i=s.length()-1;i>=0;i--){
     ret+=s.charAt(i);
   }   Â
   return ret;
 }
Â
 public BigInteger add(BigInteger s){
   String f=this.reverse(this.toString());
   String l=this.reverse(s.toString());
   int max=(f.length()>l.length())?f.length():l.length();
  Â
   String ret="";
  Â
   int carry=0;
  Â
   for(int i=0;i<max;i++){
     int sum=carry;
     if(i<f.length()){
       sum+=(f.charAt(i)-'0');
     }
     if(i<l.length()){
       sum+=(l.charAt(i)-'0');
     }
     ret+=(char)(sum%10+'0');
     carry=(sum/10);
   }
   if(carry!=0){
     ret+='1';
   }
  Â
   BigInteger bi=new BigInteger(this.reverse(ret));
   return bi;
 }
 public boolean bigNum(String s1,String s2){
      Â
   if(s1.length()>s2.length()){
     return true;
   }
   else{
     if(s1.length()<s2.length()){
       return false;
     }
     else{
       for(int i=0;i<s1.length();i++){
         if(s1.charAt(i)!=s2.charAt(i)){
           if(s1.charAt(i)>s2.charAt(i)){
             return true;
           }
           else{
             return false;
           }
         }
       }         Â
     }
   }
   return false;
 }
Â
 public BigInteger subtraction(BigInteger s){
   String f=this.toString();
   String l=s.toString();
  Â
   boolean b=this.bigNum(f, l);
 Â
   if(b==false){
     String tmp=f;
     f=l;
     l=tmp;
   }
  Â
   f=this.reverse(f);
   l=this.reverse(l);
  Â
   int max=(f.length()>l.length())?f.length():l.length();
  Â
   String ret="";
  Â
   int borrow=0;
  Â
   for(int i=0;i<max;i++){
     int sum=borrow;
     if(i<f.length()){
       sum+=(f.charAt(i)-'0');
     }
     if(i<l.length()){
       sum-=(l.charAt(i)-'0');
     }
     if(sum<0){borrow=-1;sum=10+sum;}
     else{borrow=0;}
    Â
     ret+=(char)(sum%10+'0');
   }
  Â
   if(b==false){
     ret+="-";
   }
  Â
   BigInteger bi=new BigInteger(this.reverse(ret));
   return bi;
 }
Â
 public BigInteger multiplication(BigInteger s){
   String f=this.toString();
   String l=s.toString();
Â
   int len=l.length();
  Â
   BigInteger bi=new BigInteger("");
   for(int i=len-1;i>=0;i--){
     //System.out.println(l.charAt(i));
     BigInteger r=new BigInteger(f);
     for(int j=(l.charAt(i)-'0');j>1;j--){
       r=r.add(new BigInteger(f));
       //System.out.print(r+" " );
     }
     //System.out.println();
     bi=bi.add(r);
     f=f+"0";
   }
   return bi;
 }
Â
 public BigInteger division(BigInteger s){
   BigInteger t=this;
   BigInteger bi=new BigInteger("");
   int i=0;
   t=t.subtraction(s);
   String str=t.toString();
  Â
   while(str.charAt(0)!='-' && i<40){
     //System.out.println(str+" "+(i+1));
     bi=bi.add(new BigInteger("1"));
     t=t.subtraction(s);
     str=t.toString(); Â
    Â
     i++;
   }
   return bi;  Â
 } Â
} Â
-------------------
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;
public class Driver {
 public static void main(String [] args){
   Scanner sc=new Scanner(System.in);
  Â
   String str1="";
   String str2="";
  Â
   System.out.print("Enter file name 1 :");
   String file1=sc.next();
   //String file1="datafile1.txt";
   BufferedReader reader1;
   try {
     reader1 = new BufferedReader(new FileReader(file1));
     while((str1=reader1.readLine())!=null){
       break;
     }
     reader1.close();
   } catch (FileNotFoundException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   } catch (IOException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
Â
   System.out.print("Enter file name 2 :");
   String file2=sc.next();
   //String file2="datafile2.txt";
   BufferedReader reader2;
   try {
     reader2 = new BufferedReader(new FileReader(file2));
     while((str2=reader2.readLine())!=null){
       break;
     }
     reader2.close();
   } catch (FileNotFoundException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   } catch (IOException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }