ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 103 Weeks Ago, 3 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 27 May 2017 My Price 8.00

Main.java:86: error

Please help me to fix these errors  i am getting three errors please fix ASAP

 

Main.java:86: error: cannot find symbol

int t = (a[j] * b[i]) + c[i+j] + carry;

^

symbol: variable a

location: class BigInt

Main.java:86: error: cannot find symbol

int t = (a[j] * b[i]) + c[i+j] + carry;

^

symbol: variable b

location: class BigInt

Main.java:86: error: cannot find symbol

int t = (a[j] * b[i]) + c[i+j] + carry;

^

symbol: variable c

location: class BigInt

3 errors

 

 

public class Main {

public static void main(String[] args)

{

BigInt a = new BigInt("99");

BigInt b = new BigInt("9");

System.out.println(a + " + " + b + " = " + a.add(b));

System.out.println(a + " - " + b + " = " + a.sub(b));

System.out.println(a + " * " + b + " = " + a.mul(b));

}

}

class BigInt

{

public BigInt()

{

num = new int[1];

}

public BigInt(String s)

{

num = new int[s.length()];

for (int i = 0; i {

num[num.length - i - 1] = s.charAt(i) - '0';

}

num = trim(num);

}

private BigInt(int[] n)

{

this.num = new int[n.length];

for (int i = 0; i {

this.num[i] = n[i];

}

}

public BigInt add(BigInt o)

{

int carry = 0;

int max = num.length > o.num.length ? num.length : o.num.length;

int[] result = new int[max+1];

for (int i = 0; i {

int top = i int bot = i result[i] = (top + bot + carry) % 10;

carry = (top + bot + carry) / 10;

}

return new BigInt(trim(result));

}

public BigInt sub(BigInt o)

{

int borrow =10;

int max = num.length > o.num.length ? num.length : o.num.length;

int[] result = new int[max];

int x = 0;

for (int i = 0; i {

int top = i int bot = i if (top if(x > 0)

{

result[i] = ((((top - x)+borrow))-bot);

x = 0;

x += 1;

}

else

{

result[i]= (top - bot) + borrow;

num[i+1] -= 1;

}

if( top == bot || top > bot)

result[i] = (top - bot) % 10;

}

return new BigInt(trim(result));

}

 

public BigInt mul(BigInt o)

{

int max = num.length > o.num.length ? num.length : o.num.length;

int[] result = new int[max];

for(int i=0;i {

int carry = 0;

for(int j=0;j {

int t = (a[j] * b[i]) + c[i+j] + carry;

carry = t/10;

result[i+j] = t%10;

}

}

return new BigInt(trim(result));

}

public String toString()

{

String s = "";

for (int i : num)

{

s = i + s;

}

return s;

}

private int[] trim(int[] nums)

{

int size = nums.length;

 

for (int i = nums.length - 1; i > 0; --i)

{

if (nums[i] != 0)

{

break;

}

--size;

}

int[] res = new int[size];

for (int i = 0; i {

res[i] = nums[i];

}

return res;

}

private int[] num;

}

Answers

(11)
Status NEW Posted 27 May 2017 05:05 AM My Price 8.00

-----------

Attachments

file 1495864456-Solutions file 2.docx preview (51 words )
H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly -----------onl-----------ine----------- an-----------d g-----------ive----------- yo-----------u e-----------xac-----------t f-----------ile----------- an-----------d t-----------he -----------sam-----------e f-----------ile----------- is----------- al-----------so -----------sen-----------t t-----------o y-----------our----------- em-----------ail----------- th-----------at -----------is -----------reg-----------ist-----------ere-----------d o-----------n -----------THI-----------S W-----------EBS-----------ITE-----------. ----------- Th-----------ank----------- yo-----------u -----------
Not Rated(0)