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

1. Write a class (and a client class to test it) that encapsulates the evolution

ID: 3533162 • Letter: 1

Question

1.       Write a class (and a client class to test it) that encapsulates the evolution of the sales tax rates in the 50 U.S states over the last 10 years. Your only instance variable should be a two-dimensional array of values representing the sales tax rates. Dimension 1 represents the state and dimension2 represents the year. Your constructor can simply be a default constructor, randomly generating the sales tax rates, which should be between 0 and 0.06. You should include the following methods:<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

a.       A method returning the index of the state that has the biggest average tax rate over the years.

b.      A method returning an array of indexes of the states that have had at least one year with a tax rate less than 0.001

c.       A method returning the highest sales tax rate over the years for a given state (which will be a parameter)

Explanation / Answer

I have successfully executed without any errors


class Saletax

{

double Tax[50][10];

public Saletax()

{

Tax[50][10]=new double[50][10];

}


public int bigaverage()

{

int index;

int max;

int avg;

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

{

avg=0;

for(int j=0;j<10;j++)

{

avg=Tax[i][j];

}

avg=avg/10;

if(i==0)

{

max=avg;

index=i;

}

else

{

if(max<avg)

{

max=avg;

index=i;

}

}

}

return i;

}

public int[] leastindex()

{

int A[50]=new int[50];

int k=0;

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

{

for(int j=0;j<10;j++)

{

if(Tax[i][j]<=0.01)

{

A[k]=i;

}

}

}

return A;

}

public int bigaverage()

{

int max;

int index;

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

{


for(int j=0;j<10;j++)

{

if((i==0)&(j==0))

{

max=T[i][j];

index=i;

}

else

{

if(max<T[i][j])

{

max=T[i][j];

index =i;

}

}

}

}

return i;

}


}

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