Week 3 Solution

$30.00

Category:

Description

Objective: To understand the concepts of Array and Constructor.

Assignments:

  1. Write a Java program to calculate Sum & Average of an integer array.

  1. Write a Java program to implement stack using array.

  1. Write a Java program to implement Queue using array.

  1. Write a Java program to calculate Sum of two 2-dimensional arrays.

  1. Write a Java program to find the range of a 1D array.

  1. Write a Java program to search an element in an array.

  1. Write a Java program to find the sum of even numbers in an integer array.

  1. Write a Java program to find the sum of diagonal elements in a 2D array.

  1. Reverse the elements in an array of integers without using a second array.

  1. Write a Java program to enter n elements in an array and find smallest number among them.

  1. Write Java program to find the sum of all odd numbers in a 2D array.

  1. Write a Java program to print transpose of matrix.

  1. Write a Java program to check whether a given matrix is sparse or not.

  1. Write a Java program to count the prime numbers in an array.

  1. Write a Java program to find second highest element of an array.

  1. Write a Java program which counts the non-zero elements in an integer array.

  1. Write a Java program to merge two float arrays.

  1. Write a Java program where elements of two integer arrays get added index wise and get stored into a third array.

  1. Write a Java program to multiply two matrices.

  1. Write a Java program to subtract two matrices.

  1. Write a Java program to find duplicate elements in a 1D array and find their frequency of occurrence.

  1. Write a Java program to print every alternate number of a given array.

  1. Given are two one-dimensional arrays A & B, which are sorted in ascending order. Write a Java program to merge them into single sorted array C that contains every item from arrays A & B, in ascending order.

  1. Write a Java program to show 0-arguments constructor.

  1. Write a Java program to show parameterized constructor.

  1. Write a Java program to show constructor overloading.

  1. Write a class, Grader, which has an instance variable, score, an appropriate constructor and appropriate methods. A method, letterGrade() that returns the letter grade as O/E/A/B/C/F.

Now write a demo class to test the Grader class by reading a score from the user, using it to create a Grader object after validating that the value is not negative and is not greater then 100. Finally, call the letterGrade() method to get and print the grade.

  1. Write a class, Commission, which has an instance variable, sales; an appropriate constructor; and a method, commission() that returns the commission.

Now write a demo class to test the Commission class by reading a sale from the user, using it to create a Commission object after validating that the value is not negative. Finally, call the commission() method to get and print the commission. If the sales are negative, your demo should print the message “Invalid Input”.


error: Content is protected !!