Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In Java Programming Please help, we have been running into trouble after trouble

ID: 3744121 • Letter: I

Question

In Java Programming

Please help, we have been running into trouble after trouble on this assignment. Once seen fully implemented it might be easier.

For our assignment, we must first take a string, splice it into an arraylist (123456789 becomes [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ])

We must add two arraylists together to create the sum in a method

(arraylist1[ 1 , 2 , 3 ] + arraylist2[ 2 , 3 , 4 ] = arraylist3[ 3 , 5 , 7 ])

We must multiply two arraylists together to create the product in a method

(arraylist1[ 1 , 2 , 3 ] + arraylist2[ 2 , 3 , 4 ] = arraylist3[ 2 , 8 , 7 , 8 , 2])

We must compare two arraylists to see when arraylist holds the larger value in a method

(arraylist1[ 1 , 2 , 3 ] arraylist2[ 2 , 3 , 4 ] return: arraylist2 OR [ 2 , 3 , 4 ]

We must compare two arraylists to see when arraylist holds the smaller value in a method

(arraylist1[ 1 , 2 , 3 ] arraylist2[ 2 , 3 , 4 ] return: arraylist1 OR [ 1 , 2 , 3 ]

Full Specifications in pic

Basically you go from a string to an arraylist. then do the min, max add, multiply method, then back to a string. If you need any additional clearification please provide details. I have parts working, I just cannot make the program function as a whole.

Prograiming Enter options d Would you like to select another option? (y/n) n Would you like to enter another polynomial? (y/n) a class java. lang.Bigtnteger that can be used to handle very large ntegers. Implement a similar class, called Bigtnt, that can be used to do simpe will need the following n A data calculations with very large nonnegative integers. Design this arefully. You structure to represent large numbers: for example, a string or an array or the digits in a number. . public Bigint(String val) A constructor that uses a string representation of the integer The string may contain leading zeros. Do not forget that zero is a valid nu public String tostring) Returns t for initialization. h String representation of this Bigint. It should not include zeros, but if the number consists of all zeros, it should return a String with a single zero. public BigInt max ( BigInt val) A method that r instance of BigInt that invokes max eturns a Bigint whose value is the maximum of val and the public BigInt min(Bigint val) A method that returns a B instance of BigInt that invokes min igint whose value is the minimum of val and the - public BigInt add(BigInt val) A method that returns a Bigint whose value is the sum of val and the instance of BigInt that invokes add. public BigInt multiply(BigInt val) A method that returns a BigInt whose value is the product of val and the instance of BigInt that invokes multiply. Write a program that acts as an interactive calculator capable of handling very large nonnegative integers that uses the BigInt class. This calculator need perform only the operations of addition and multiplication. In this program each input line is of the form and should produce output such as op mump where numi and num2 are (possibly very large) nonnegative integers, op is the single character + or *, and nuwg is the integer that results from the desired calcu- lation. Be sure your interface is user friendly Optional: Allow signed integers (negative as well as positive integers), and write a method for subtraction.

Explanation / Answer

// Java program to demonstrate working of ArrayList in Java

import java.io.*;

import java.util.*;

class sortl{

  

public ArrayList<Integer> sortlist( ArrayList<Integer> arrli1){

ArrayList<Integer> temp2;

Collections.sort(arrli1);

return arrli1;

}

}

class arrayli

{

public static void main(String[] args)

throws IOException

{

  

Scanner scan = new Scanner(System.in);

//input taken from cmd line

System.out.println(" Enter List 1:");

String s = scan.next();

System.out.println(" Enter List 2:");

String s1 = scan.next();

ArrayList<Integer> arrli = new ArrayList<Integer>(s.length());

ArrayList<Integer> arrli1 = new ArrayList<Integer>(s1.length());

// convert string to ArrayList

for(int i=0;i<s.length();i++)

{

int cr = s.charAt(i) - '0';

arrli.add(cr);

}

for(int i=0;i<s1.length();i++)

{

int cr = s1.charAt(i) - '0';

arrli1.add(cr);

}

System.out.println("List 1:");

System.out.println(arrli);

System.out.println("List 2:");

System.out.println(arrli1);

//call function of module

ArrayList<Integer> addlist=addArrayList(arrli,arrli1,s1.length());

ArrayList<Integer> Multiplylist1=multiplyArrayList(arrli,arrli1,s1.length());

ArrayList<Integer> minlist1=minArrayList(arrli,arrli1,s1.length());

ArrayList<Integer> maxlist1=maxArrayList(arrli,arrli1,s1.length());

System.out.println("List Added Above two list");

System.out.println(addlist);

System.out.println("List Multiply Above two list");

System.out.println(Multiplylist1);

System.out.println("Min List Above two list");

System.out.println(minlist1);

System.out.println(" Max List Above two list");

System.out.println(maxlist1);

//make ArrayList to StringBuilder

StringBuilder sb = new StringBuilder();

StringBuilder sb1 = new StringBuilder();

StringBuilder sb2 = new StringBuilder();

StringBuilder sb3 = new StringBuilder();

for (int i = 0; i < s.length(); i++)

{

sb.append(addlist.get(i).toString());

sb1.append(Multiplylist1.get(i).toString());

sb2.append(minlist1.get(i).toString());

sb3.append(maxlist1.get(i).toString());

}

//show output and input string

System.out.println("The number string of input List1 = " + s);

System.out.println("The number string of input List2 = " + s1);

System.out.println("The number string of Add List = " + sb.toString());

System.out.println("The number string of Multiply List = " + sb1.toString());

System.out.println("The number string of Min List = " + sb2.toString());

System.out.println("The number string of Max List = " + sb3.toString());

}

public static ArrayList<Integer> addArrayList(ArrayList<Integer>arrli,ArrayList<Integer>arrli1,int size){

ArrayList<Integer> arr = new ArrayList<Integer>(size);

for (int i=0; i<size; i++)

{ int temp=arrli.get(i)+arrli1.get(i);

arr.add(temp);

}

return arr ;

}

  

public static ArrayList<Integer> multiplyArrayList(ArrayList<Integer>arrli,ArrayList<Integer>arrli1,int size){

ArrayList<Integer> arr = new ArrayList<Integer>(size);

for (int i=0; i<size; i++)

{ int temp=arrli.get(i)*arrli1.get(i);

arr.add(temp);

}

return arr ;

}

public static ArrayList<Integer> minArrayList(ArrayList<Integer>arrli,ArrayList<Integer>arrli1,int size){

ArrayList<Integer> arr = new ArrayList<Integer>(size);

sortl s1=new sortl();

ArrayList<Integer> temp,temp1,temp2;  

temp=s1.sortlist(arrli);

temp1=s1.sortlist(arrli1);

for (int i=0; i<size; i++)

{ if(temp.get(i)>temp1.get(i))

return arrli1;

if(temp1.get(i)>temp.get(i))

return arrli;

}

return arrli;

}

public static ArrayList<Integer> maxArrayList(ArrayList<Integer>arrli,ArrayList<Integer>arrli1,int size){

ArrayList<Integer> arr = new ArrayList<Integer>(size);

sortl s1=new sortl();

ArrayList<Integer> temp,temp1,temp2;  

temp=s1.sortlist(arrli);

temp1=s1.sortlist(arrli1);

for (int i=0; i<size; i++)

{ if(temp.get(i)<temp1.get(i))

return arrli1;

if(temp1.get(i)<temp.get(i))

return arrli;

}

return arrli;

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote