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

Need help creating code/ editing for this assignment if you look at the picture

ID: 3816035 • Letter: N

Question

Need help creating code/ editing for this assignment if you look at the picture and within the code will have tasks and will show what to do. Here is the code that I created.

//lab5b ,name, cssc

import java.util.*;
import java.lang.*;
import java.io.*;


public class SetComparison
{

public static void main(String[] args)
{
double[] arr1 =new double[10];
double[] arr2 =new double[10];
int a,b;
Scanner con = new Scanner(System.in);
  
  
System.out.println("Enter the size of Array 1");
do{
a = con.nextInt();
}while(con.hasNextInt());
  
System.out.println("Enter the size of Array 2");
do{
b = con.nextInt();
}while(con.hasNextInt());
  
if (a == b)
{
System.out.println("Enter the values of Array 1");
for (int i=0;i<a;i++)
arr1[i]=con.nextDouble();
  
System.out.println("Enter the values of Array 2");
for (int i=0;i<b;i++)
arr2[i]=con.nextDouble();
  
for (int i=0;i<a;i++)
{
if((Math.abs(arr1[i]-arr2[i])>0.001))
System.out.println("the values are not same ");
  
else
System.out.println("the values are same ");
}
  
}

else
System.out.println("The Array sizes are not same ");
}
}

1. Compare output 45.24 54.67 2.55 44. 61 65.29 49.75 Input 6 45.24 54.67 42.55 44.61 65.29 49 75 Enter the size of Array 1 Enter the size of Array 2 Exception in thread "main java .util. InputMismatchExcep at java .util Scanner. throw For (Scanner java: 909) Your output at java util. Scanner next (Scanner java: 1530) at java util. Scanner next Int (Scanner. java: 2160) at java. util. Scanner. next. Int (Scanner .java: 2119) at SetComparison .main (SetComparison.java :26) set one and set two are equal Expected output 2. Compare output 45.24 54.67 42.55 44. 61 65.29 49 75 Input 6 45.24 54.67 41.99 44. 61 65.29 49.75 Enter the size of Array Enter the size of Array 2 Exception in thread "main" java util. InputMismatchExcep att java util. Scanner throw For (Scanner java: 909) Your output at java .util. Scanner next (Scanner. java: 1530) at java. util Scanner nextInt (Scanner java :2160) at java util. Scanner. next. Int (Scanner.java 2119) at SetComparison main (SetComparison.java: 26 Expected output set one and set two are not equal 3. Compare output 45.24 54.67 42.55 Input 5 45.24 54.67 42.55 44. 61 65.29 49.75 Enter the size of Array 1 Enter the size of Array 2

Explanation / Answer

//lab5b ,name, cssc
import java.util.*;
import java.lang.*;
import java.io.*;

public class SetComparison
{
public static void main(String[] args)
{
int count = 0; //variable to manipulate while comparing arrays
Scanner con = new Scanner(System.in);
int array1size = 0;
int array2size = 0;
  
System.out.println("Enter the size of Array 1");
array1size = con.nextInt();
double[] arr1 =new double[array1size];
  
System.out.println("Enter the size of Array 2");
array2size = con.nextInt();
double[] arr2 =new double[array2size];
  
if (array1size == array2size)
{
System.out.println("Enter the values of Array 1");
  
for (int i=0;i<array1size;i++)
arr1[i]=con.nextDouble();
  
System.out.println("Enter the values of Array 2");
  
for (int i=0;i<array2size;i++)
arr2[i]=con.nextDouble();
  
for (int i=0;i<array2size;i++)
{
if((Math.abs(arr1[i]-arr2[i])>0.001)){
count++;
System.out.println("The values of arr1[" + i + "] and arr2[" + i + "] are not equal");
break;
}
}
  
if(count == 0){
System.out.println("set one and two are equal");
}else{
System.out.println("set one and two are not equal");
}
}
else
System.out.println("The Array sizes are not same ");
}
}

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