Write a program that has the class name Problem1 and that has the main method. Leave...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
• Write a program that has the class name Problem1 and that has the main method. Leave the main method empty for now. • Write a method named repeat Char that takes two parameters, an integer array arr and a character array ch, having the same length and returns a 2D array. Each row of the returned 2D array has each character from ch array, arr[i] times. Several sample usages are provided for you below. Use the sample usages in the main method to test your code (and use the print 2 DArray method to print out the results of calling the repeatchar method!). Sample Method Usage ● int[] x1 = {4, 3, 5, 2}; char[] y1= { 'Q', 'W', 'r', 'b'}; char[][] Z1 = repeatChar (x1, y1); z1 int[] x2 = {5, 2, 3, 4, 1}; char[] y2 = { '@', '!', '<', 's', 'm'}; char[][] z2 = repeatChar (x2, y2); Return value {{ 'Q', 'Q', 'Q', 'Q' }, { 'W', 'W', 'W' }, { 'r', 'r', 'r', 'r', 'r' }, { 'b', 'b' } }; '@', '@', '@', "@" }, { { '@', {! { { 'm' } }; 's', 's', 's' }, A Go Problem 2. Define a class named Airport that has the following An instance variable named name of type String An instance variable named capacity of type int An instance variable named rank of type int A constructor that takes no argument and sets name to "SkyFly", capacity to 3, and rank to 1. The constructor's header is Airport() ● A constructor that takes three parameters and sets the instance variables accordingly. The constructor's header is Airport(String newName, String newCapacity, double newRank) An instance method that displays the instance variables of the invoking object in a format of your choice. The method's header is void display Airport() • Write a program that has the class name Problem1 and that has the main method. Leave the main method empty for now. • Write a method named repeat Char that takes two parameters, an integer array arr and a character array ch, having the same length and returns a 2D array. Each row of the returned 2D array has each character from ch array, arr[i] times. Several sample usages are provided for you below. Use the sample usages in the main method to test your code (and use the print 2 DArray method to print out the results of calling the repeatchar method!). Sample Method Usage ● int[] x1 = {4, 3, 5, 2}; char[] y1= { 'Q', 'W', 'r', 'b'}; char[][] Z1 = repeatChar (x1, y1); z1 int[] x2 = {5, 2, 3, 4, 1}; char[] y2 = { '@', '!', '<', 's', 'm'}; char[][] z2 = repeatChar (x2, y2); Return value {{ 'Q', 'Q', 'Q', 'Q' }, { 'W', 'W', 'W' }, { 'r', 'r', 'r', 'r', 'r' }, { 'b', 'b' } }; '@', '@', '@', "@" }, { { '@', {! { { 'm' } }; 's', 's', 's' }, A Go Problem 2. Define a class named Airport that has the following An instance variable named name of type String An instance variable named capacity of type int An instance variable named rank of type int A constructor that takes no argument and sets name to "SkyFly", capacity to 3, and rank to 1. The constructor's header is Airport() ● A constructor that takes three parameters and sets the instance variables accordingly. The constructor's header is Airport(String newName, String newCapacity, double newRank) An instance method that displays the instance variables of the invoking object in a format of your choice. The method's header is void display Airport()
Expert Answer:
Answer rating: 100% (QA)
Problem 1 Problem1java public class Problem1 method that takes an int array and a char arr... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
What is the simple interest and compound interest in the UCLA student loans? Explain
-
The organizing committee for the HCC Celebrates Columbia's 50th Birthday, Inc., has planned a special event commemorating notable people originally from Columbia, MD. The committee has invited the...
-
1. John was employed by ABC Accounting, a CPA firm, for three years. As a condition of employment, he was required to sign a covenant not to compete. He left the firm in 2020 to start a new...
-
Find the distance between the given pairs of points. (32, 18) and (50, 8)
-
Color Explosion prepares and packages paint products. Color Explosion has two departments: Blending and Packaging. Direct materials are added at the beginning of the blending process (dyes) and at...
-
Excursion Publishing was recently organized. The company issued common stock to an attorney who provided legal services worth $20,000 to help organize the corporation. Excursion also issued common...
-
A fixed mass of gas emits \(250 \mathrm{~J}\) of heat energy and contracts at a constant pressure of \(1 \times 10^{5} \mathrm{~Pa}\) from \(2.5 \times 10^{-3} \mathrm{~m}^{3}\) to \(1.0 \times...
-
An evaluation of the books of Blair Supply, which follows, gives the end-of-year accounts receivable balance, which is believed to consist of amounts originating in the months indicated. The company...
-
Explain Utility theory and its application in Covid-19 Pandemic as a macroeconomic public policy response and its importance as a decision making tool. Explain Prospect theory and its application in...
-
TV Trends to Watch in 2021 In 2021, expect larger and cheaper 4K TVs, a new level of voice control, interaction with other smart products, and mini Led backlights to improve color contrast and...
-
SeatGeek is an online ticket platform, helping you to sell and buy tickets for theatre events, live sports, and concerts. SeatGeek has both desktop and mobile platforms, designed to show information...
-
How do network externalities increase the winner-take-all nature of a market?
-
Why would push instead of nudge policies be required?
-
How does behavioral economics undermine the standard supply/demand model? (Institutionalist)
-
Taking into consideration changing technologies, why might the competitive process not lead to the most efficient outcome?
-
There is an implicit view in the chapter that if a policy meets the libertarian paternalistic goal, it is a good policy. Is that necessarily the case? (Radical)
-
(i) Year 1 Renewal years Expenses Percent of premium 65% 5% Per policy 12 2 (ii) 40 = 14 (iii) 40.20 = 10 (iv) i = 0.05 (v) Gross premiums are determined using the equivalence principle. Determine...
-
The trade-off theory relies on the threat of financial distress. But why should a public corporation ever have to land in financial distress? According to the theory, the firm should operate at the...
-
Provide code for a constructor for the bank account class from Chapter Review Question 5. Data From Question 5 Define a class to represent a bank account. Data members should include the depositors...
-
The CandyBar structure contains three members.The first member holds the brand name of a candy bar.The second member holds the weight (which may have a fractional part) of the candy bar, and the...
-
The Bank of Heather has performed a study showing that ATM customers wont wait more than one minute in line. Using the simulation from Listing 12.10, find a value for number of customers per hour...
-
S1 Ltd and S2 Ltd belong to the same capital gains group. In May 2020, S1 Ltd transferred a chargeable asset to S2 Ltd. The original cost of this asset to S1 Ltd was 10,000 and its market value in...
-
The ordinary share capital of W Ltd (which is a trading company) is owned 30% by X Ltd, 25% by Y Ltd and 45% by Z Ltd. All of these companies are UK resident and they prepare accounts to 31 March....
-
E Ltd has taxable total profits of 800,000 for the year to 31 March 2024 and receives no dividends. For many years, the company has owned 65% of the ordinary shares of F Ltd and 30% of the ordinary...
Study smarter with the SolutionInn App