1.1 Write a Java program which stores a pair of values and support following methods: getFirst,...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
1.1 Write a Java program which stores a pair of values and support following methods: getFirst, getSecond, setFirst and setSecond. (100 points) 1. Define a Pair class that has: Two elements (first, second), A constructor and Four 2. methods(getFirst, getSecond, setFirst and setSecond). Implement test class TestPair that Define an array(length is 10) of Pair type. • Type of first - int, type of second - double. Set the value of array.first: (0, 1, 2, ..., 8, 9). Set the value of array.second: (9.0, 8,0, ..., 1.0, 0.0). Print out the array. ● ● 1.2 Please Modify the homework1.1 by using Java Generics. (Declare two elements by using formal type parameters). (Extra 50 points) 1.1 Write a Java program which stores a pair of values and support following methods: getFirst, getSecond, setFirst and setSecond. (100 points) 1. Define a Pair class that has: Two elements (first, second), A constructor and Four 2. methods(getFirst, getSecond, setFirst and setSecond). Implement test class TestPair that Define an array(length is 10) of Pair type. • Type of first - int, type of second - double. Set the value of array.first: (0, 1, 2, ..., 8, 9). Set the value of array.second: (9.0, 8,0, ..., 1.0, 0.0). Print out the array. ● ● 1.2 Please Modify the homework1.1 by using Java Generics. (Declare two elements by using formal type parameters). (Extra 50 points)
Expert Answer:
Answer rating: 100% (QA)
a java program which stores a pair of values and supports the following methods getFirst getSecond setFirst setSecond Here is the solution java public ... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
answer the question clearly You are building a flight-control system for which a convincing safety case must be made. Would you assign the tasks of safety requirements engineering, test case...
-
A production supervisor at a major chemical company wishes to determine whether a new catalyst, catalyst XA-100, increases the mean hourly yield of a chemical process beyond the current mean hourly...
-
Triumph Company prepares reversing entries. If the adjusting entry for interest payable is reversed, what type of an account balance, if any, will there be in Interest Payable and Interest Expense...
-
As more and more companies span the globe in terms of their operating, financing, and investing activities, they will increasingly turn to international financial reporting standards when...
-
Missing data and profitability analysis Summary financial information for two independent companies is presented below. Required (a) Calculate the missing amounts. (b) Calculate the gross profit...
-
Lily Company has historically reported a bad debt expense amount of between 1% and 4% of sales. The percentage for any given year is a function of both the business conditions for the year and...
-
a) Explain the following terms as used in real estate appraisals i. Value in use ii. iii. Liquidation value Insurable value b) Describe the cost approach of real estate valuation c) Explain the...
-
On March 1, 2019, PT Maju purchased a cash supply of 500 boxes of fresh detergent soap merchandise @ 24 packs with a total purchase value of IDR 108,000,000. On April 1, 2019, all of the Fresh...
-
What must a retail store's design team consider when designing their store environment to create excitement? Explain.
-
Decision Point: Where Do You Go from Here? After talking with some design engineers and sales associates, you think that the audience will be resistant to your message and may not perceive the value...
-
Write a Research Essay that analyzes a specific idea within a broader topic, with factual evidence and academic sources to back up your interpretation/thesis. Making sure that you have a specific...
-
1. You have a new team member participating in a project at work. This team member will be analyzing data that other team members are already gathering. The main person in charge of the project will...
-
How to identify and select your quality improvement project idea/problem if data not available?
-
The four graphs below represent wave functions of an electron in an infinite one-dimensional square well of width L = 0.08 nm. The wave functions are, of course, zero outside the well. wave function...
-
Refer to the situation described inBE 18-13, but assume a 2-for-1 stock split instead of the 5% stock dividend. Prepare the journal entry to record the stock split if it is to be effected in the form...
-
Write a graphical application simulating a bank account. Supply text fields and buttons for depositing and withdrawing money, and for displaying the current balance in a label.
-
Find three run-time errors in the following program. public class HasErrors { public static void main(String[] args) { int x = 0; int y = 0; Scanner in = new Scanner("System.in");...
-
Add error handling to Exercise E3.11. If the user does not enter a number when expected, or provides an invalid unit for the altitude, print an error message and end the program. Data from Exercise...
-
Define marketing environment, and discuss the two parts that make up a companys marketing environment.
-
Technological advances are perhaps the most dramatic forces affecting todays marketing strategies. Imagine you are in the marketing department of a major brand familiar to you. How might new...
-
Consumers in the United Kingdom seem to be at the mercy of their own insurers. Hidden within the close print of the renewal notices is the true cost of renewing the insurance, often as much as a 100...
Study smarter with the SolutionInn App