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

Below is my code and here are the errors I am getting? MyIntegerChacon.java:94:

ID: 3573700 • Letter: B

Question

Below is my code and here are the errors I am getting?

MyIntegerChacon.java:94: error: ')' expected

char[] a=("1" "2" "3" "4" );

^

MyIntegerChacon.java:94: error: not a statement

char[] a=("1" "2" "3" "4" );

^

MyIntegerChacon.java:94: error: ';' expected

char[] a=("1" "2" "3" "4" );

^

3 errors

import java.io.*;
import java.util.Scanner;

class MyIntegerChacon
{
int value;

MyIntegerChacon(int number)
{
value = number;
}
public int getValue()
{
return value;
}
public static boolean isEven(int n)
{
return (n % 2 == 0);
}
public static boolean isOdd(int n)
{
return !isEven(n);
}
public static boolean isPrime(int n)
{
for (int f=2; f < n/2; f++)
{
if (n % f == 0)
{
return false;
}
}
return true;
}
public static boolean isEven(MyInteger n)
{
return n.isEven();
}
public static boolean isOdd(MyInteger n)
{
return n.isOdd();
}
public static boolean isPrime(MyInteger n)
{
return n.isPrime();
}
public boolean isEven()
{
return isEven(value);
}
public boolean isOdd();
{
return isOdd(value);
}
public boolean isPrime()
{
return isPrime(value);
}
public boolean equals(int n)
{
return (value == n);
}
public boolean equals(MyInteger n)
{
return equals(n.getValue());
}
public static int parseInt(String s)
{
return Integer.parseInt(s);
}
public static int parseInt(char[] s)
{
return parseInt(new String(s));
}

public class TestMyIntegerChacon

{

public static void main(String[] args)

{

Scanner input=new Scanner(System.in);

System.out.println(" Enter a number ");

int a=input.nextInt();

MyInteger i1=new MyInteger(a);

System.out.println( a+ " is even? " +i1.isEven());

System.out.println( a+ " is odd ? " +i1.isOdd());

System.out.println( a+ " is Prime ? "+i1.isPrime());

System.out.prinln( " 17 is prime? " +MyInteger.isPrime(17));

char[] a=("1" "2" "3" "4" );

System.out.println( " characters " +MyInteger.parseInt(c));

String s="123456789" ;

System.out.println( "String is " +MyInteger.parseInt(s));

System.out.println( "19 is odd? " +MyInteger.isOdd(19));

System.out.println(a+ " is equal to 24 ? " + i1.equals(24));

}

}

Explanation / Answer


// MyIntegerChacon.java

import java.io.*;
import java.util.Scanner;
class MyIntegerChacon
{
int value;

MyIntegerChacon(int number)
{
value = number;
}
public int getValue()
{
return value;
}
public static boolean isEven(int n)
{
return (n % 2 == 0);
}
public static boolean isOdd(int n)
{
return !isEven(n);
}
public static boolean isPrime(int n)
{
for (int f=2; f < n/2; f++)
{
if (n % f == 0)
{
return false;
}
}
return true;
}
public static boolean isEven(MyIntegerChacon n)
{
return n.isEven();
}
public static boolean isOdd(MyIntegerChacon n)
{
return n.isOdd();
}
public static boolean isPrime(MyIntegerChacon n)
{
return n.isPrime();
}
public boolean isEven()
{
return isEven(value);
}
public boolean isOdd()
{
return isOdd(value);
}
public boolean isPrime()
{
return isPrime(value);
}
public boolean equals(int n)
{
return (value == n);
}
public boolean equals(MyIntegerChacon n)
{
return equals(n.getValue());
}
public static int parseInt(String s)
{
return Integer.parseInt(s);
}
public static int parseInt(char[] s)
{
return parseInt(new String(s));
}
}

// TestMyIntegerChacon.java
import java.io.*;
import java.util.Scanner;

public class TestMyIntegerChacon
{
   public static void main(String[] args)
   {
       Scanner input=new Scanner(System.in);
       System.out.println(" Enter a number: ");
       int a=input.nextInt();
       MyIntegerChacon i1=new MyIntegerChacon(a);
       System.out.println( a+ " is even? " +i1.isEven());
       System.out.println( a+ " is odd ? " +i1.isOdd());
       System.out.println( a+ " is Prime ? "+i1.isPrime());
       System.out.println( " 17 is prime? " +i1.isPrime(17));
       char[] c={'1' ,'2', '3', '4' };
       System.out.println( " characters " +i1.parseInt(c));
       String s="123456789" ;
       System.out.println( "String is " +i1.parseInt(s));
       System.out.println( "19 is odd? " +i1.isOdd(19));
       System.out.println(a+ " is equal to 24 ? " + i1.equals(24));
   }
}

/*
output:

Enter a number:
23
23 is even? false
23 is odd ? true
23 is Prime ? true
17 is prime? true
characters 1234
String is 123456789
19 is odd? true
23 is equal to 24 ? false


*/

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