Order For Similar Custom Papers & Assignment Help Services

Fill the order form details - writing instructions guides, and get your paper done.

Posted: February 24th, 2022

Programming Assignment #3

 
Assignment Content

Using the example code for the generic PrintArray that was presented in class (also provided below), modify the code to overload the generic method of PrintArray twice for each of the following:

take two additional integer arguments, low and high, entered by the user. When you call the method with these arguments, it prints out only the portion of the array that is between the two subscripts. Your program needs to validate that the low and high are within the range of the array bounds. If either is out of range, then the overloaded PrintArray method should throw and InvalidSubscriptException; The exception should be caught by the main program and an error message to the user should notify them of the issue and allow them to enter a correct value. If no exception is thrown, then printArray should return the number of elements printed. This is a custom exception. The code for the exception class is provided below the PrintArray code.
Overload the generic PrintArray with a non-generic version of the method that specifically prints an array of Strings (you can make up your own names to use in the array) in neat, tabular format as shown below:
The following names are in the array;
Tom Abdul Han Mark
Sara Hamilton Anna Tatiana

You will need to modify the main program to exercise all versions of the overloaded method. For the addition of two integer arguments, you need to exercise both versions of printArray on all three array types (integer, double, and character). For the non-generic version, you need to show the ability to exercise the method and print out the nicely formatted string array content.

Make sure to submit your java code file(s) and your execution screenshots. Don’t forget to include a program header with your name, section, assignment title, and a description of the program. The execution screenshots are required for credit. Make sure to submit your own original code. SafeAssign has been enabled to verify originality of code.

// Using generic methods to print array of different types.

public class GenericMethodTest 
{
  // generic method printArray
  public static < E > void printArray( E[] inputArray )
  {
   // display array elements
   for ( E element : inputArray )
     System.out.printf( “%s “, element );

   System.out.println();
  } // end method printArray

  public static void main( String args[] ) 
  {
   // create arrays of Integer, Double and Character
   Integer[] integerArray = { 1, 2, 3, 4, 5, 6 , 7, 8, 9, 10};
   Double[] doubleArray = { 1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7 , 8.8, 9.9, 10.1};
   Character[] characterArray = { ‘I’, ‘S’, ‘2’, ‘4’, ‘7’ ,’ ‘ , ‘i’, ‘s’, ‘ ‘ , ‘f’, ‘u’, ‘n’};

   System.out.println( “Array integers:” );
   printArray( integerArray ); // pass an Integer array 
   System.out.println( “nArray doubles:” );
   printArray( doubleArray ); // pass a Double array
   System.out.println( “nArray characters:” );
   printArray( characterArray ); // pass a Character array
  } // end main
} // end class GenericMethodTest

public class InvalidSubscriptException extends RuntimeException {
// no-argument constructor
public InvalidSubscriptException() {
this(“Invalid subscript.”);
  } 

// one-argument constructor
public InvalidSubscriptException(String message) {
super(message);
  } 

// two-argument constructor
public InvalidSubscriptException(String message, Throwable cause) {
super(message, cause);
  } 
}

Order | Check Discount

Tags: Assignments Essays Online, best research paper writing service, best website for nursing assignment, Buy Case Study Online, Buy Cause And Effect Essay

Assignment Help For You!

Special Offer! Get 20-25% Off On your Order!

Why choose us

You Want Quality and That’s What We Deliver

Top Skilled Writers

To ensure professionalism, we carefully curate our team by handpicking highly skilled writers and editors, each possessing specialized knowledge in distinct subject areas and a strong background in academic writing. This selection process guarantees that our writers are well-equipped to write on a variety of topics with expertise. Whether it's help writing an essay in nursing, medical, healthcare, management, psychology, and other related subjects, we have the right expert for you. Our diverse team 24/7 ensures that we can meet the specific needs of students across the various learning instututions.

Affordable Prices

The Essay Bishops 'write my paper' online service strives to provide the best writers at the most competitive rates—student-friendly cost, ensuring affordability without compromising on quality. We understand the financial constraints students face and aim to offer exceptional value. Our pricing is both fair and reasonable to college/university students in comparison to other paper writing services in the academic market. This commitment to affordability sets us apart and makes our services accessible to a wider range of students.

100% Plagiarism-Free

Minimal Similarity Index Score on our content. Rest assured, you'll never receive a product with any traces of plagiarism, AI, GenAI, or ChatGPT, as our team is dedicated to ensuring the highest standards of originality. We rigorously scan each final draft before it's sent to you, guaranteeing originality and maintaining our commitment to delivering plagiarism-free content. Your satisfaction and trust are our top priorities.

How it works

When you decide to place an order with Dissertation App, here is what happens:

Complete the Order Form

You will complete our order form, filling in all of the fields and giving us as much detail as possible.

Assignment of Writer

We analyze your order and match it with a writer who has the unique qualifications to complete it, and he begins from scratch.

Order in Production and Delivered

You and your writer communicate directly during the process, and, once you receive the final draft, you either approve it or ask for revisions.

Giving us Feedback (and other options)

We want to know how your experience went. You can read other clients’ testimonials too. And among many options, you can choose a favorite writer.