1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
strojnjashka [21]
3 years ago
12

You have been handed a mysterious piece of data by an unknown person. Judging by his shifty eyes and maniacal laughter you don't

think he can be trusted. Complete the below method to tell you the type for this unknown data. The example already implemented can be adapted for other wrapper classes as well. Complete the method to analyze String, Character, and Double. Examples: whatAmI(1) -> "Integer" 1 public String whatAmI(E e) { 3 //.getClass() returns the runtime class of an object //.equals() determines whether two objects are equivalent //by calling a new static instance of a wrapper object we can analyze //it's class type and compare it to the variable passed in if(e.getClass().equals(new Integer(1).getClass()) { return "Integer"; }else{ return "Who knows!"; Given a word, use a stack to reverse the word and return a new string with the original word in reverse order. You cannot use the reverse string methods in the String class. Examples: reverseword("hello") -> "olleh" reverseword("hallo") -> "ollah" i public String reverseWord(String word) Stack character> stack = new Stack ;
Computers and Technology
1 answer:
irga5000 [103]3 years ago
5 0

Answer:

Java Code given below with appropriate comments for better understanding

Explanation:

1.

public String whatAmI(E e) {

//.getClass() returns the runtime class of an object

//.equals() determines whether two objects are equivalent

//by calling a new static instance of a wrapper object we can analyze

//it's class type and compare it to the variable passed in

if(e.getClass().equals(new Integer(1).getClass())) {

return "Integer";

}

else if(e.getClass().equals(new String("1").getClass())) {

return "String";

}

else if(e.getClass().equals(new Double(1.0).getClass())) {

return "Double";

}

else {

return "Who knows!";

}

}

2.

public String reverseWord(String word) {

   Stack<Character> stack = new Stack<Character>();

   for (int i = 0; i < word.length(); i++) {

       stack.push(word.charAt(i));

   }

   String result = "";

   while (!stack.isEmpty()) {

       result += stack.pop();

   }

   return result;

}

You might be interested in
In C++ please (read the image below for instructions)
FromTheMoon [43]

Using the knowledge in computational language in C code  it is possible to write a code that  print the month name along with their rainfall inches. Then we have to calculate the total rainfall.

<h3>Writting the code:</h3>

<em>#include <bits/stdc++.h></em>

<em>using </em><em>namespace </em><em>std;</em>

<em />

<em>// function to print the rainfall of each month</em>

<em>void rainfallStatistics(string month[], double rainfall[]){</em>

<em>    </em>

<em>    double sum = 0; // variable to store the total sum of rainfall</em>

<em>    string maxMonth = month[0]; // variable to return month with maximum rainfall</em>

<em>    double </em><em>maxRainfall </em><em>= INT_MIN; // variable to store the maximum rainfall</em>

<em>    </em>

<em>    // running the loop till the last month</em>

<em>    for(int i=0; i<12; i++){</em>

<em>        </em>

<em>        // printing the month and rainfall</em>

<em>        cout<< month[i] << "           " << fixed << setprecision(2) << rainfall[i] << " inches" << endl;</em>

<em>        </em>

<em>        // storing the sum</em>

<em>        sum = sum + rainfall[i];</em>

<em>        </em>

<em>        // checking the month with highest rainfall</em>

<em>        if(rainfall[i] > </em><em>maxRainfall</em><em>){</em>

<em>            </em>

<em>            maxRainfall = rainfall[i];</em>

<em>            maxMonth = month[i];</em>

<em>        }</em>

<em>    }</em>

<em>    </em>

<em>    // calculating the average of the rainfall</em>

<em>    double average = sum / double(12);</em>

<em>    </em>

<em>    cout << endl;</em>

<em>    cout << "Total for the year " << sum << " inches" << endl;</em>

<em>    cout << "Average rainfall per month " << average << " inches" << endl;</em>

<em>    cout << "Month with the greatest rainfall was " << maxMonth << " with rainfall of " << </em><em>maxRainfall </em><em><< " inches" << endl;</em>

<em>    </em>

<em>}</em>

<em>// driver program</em>

<em>int main()</em>

<em>{</em>

<em>    // array to store the nonth name</em>

<em>    string month[12] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};</em>

<em>    </em>

<em>    // array to store the rainfall</em>

<em>    double rainfall1[12] = { 4.50, 4.25, 3.26, 1.35, 0.80, 0.20, 0.10, 0.00, 0.40, 1.20, 2.96, 4.71 };</em>

<em>    double rainfall2[12] = { 3.50, 1.25, 7.26, 8.35, 2.80, 0.00, 1.10, 4.00, 9.40, 2.20, 3.96, 4.71 };</em>

<em>    </em>

<em>    cout << "Hayward Statistics" << endl;</em>

<em>    cout << endl;</em>

<em>    cout<< "Month" << "         " << "Rainfall" << endl;</em>

<em>    </em>

<em>    // calling the function for Hayward</em>

<em>    </em><em>rainfallStatistics</em><em>(month, rainfall1);</em>

<em>    cout << endl;</em>

<em>    cout << endl;</em>

<em>    </em>

<em>    cout << "Houston Statistics" << endl;</em>

<em>    cout << endl;</em>

<em>    cout<< "Month" << "         " << "Rainfall" << endl;</em>

<em>    </em>

<em>    // calling the function for Houston</em>

<em>    rainfallStatistics(month, rainfall2);</em>

<em>    </em>

<em>    return 0;</em>

<em>}</em>

See more about c code at brainly.com/question/19705654

#SPJ1

8 0
2 years ago
After 4th collision in ethernet, find the maximum time that the adapter waits until sensing the channel again for a 100 mbps bro
VARVARA [1.3K]

Waiting time for a 100 Mbps broadcast channel is 0.512 ms

Recall that with the CSMA/CD protocol, the adapter waits K * 512 bit times after a collision,

where K is drawn randomly. For K = 100,

The one bit time for 10 Mbps is 1/10000000 s = 0.0001 ms

The one bit time for 100 Mbps is 1/100000000 s = 0.00001 ms

Waiting time for a 10 Mbps broadcast channel is K*512*0.0001= 5.12 ms

Waiting time for a 100 Mbps broadcast channel is K*512*0.00001= 0.512 ms

<h3>What is a collision in Ethernet?</h3>
  • A collision happens on a half-duplex Ethernet network when two devices on the same network attempt to communicate data at the exact same time.
  • The two transmitted packets are "collapsed" by the network, which results in the network discarding both of them.
  • On Ethernets, collisions are unavoidable.
  • A collision is a momentary interaction between two bodies or more than two bodies at once that modifies the motion of the bodies involved as a result of the internal forces at work.
  • Collisions entail the application of force (there is a change in velocity).

Learn more about collision in Ethernet: brainly.com/question/14123270

#SPJ4

3 0
2 years ago
What is a sign that content is
Sidana [21]
D. All of the above
7 0
4 years ago
Read 2 more answers
What is an indication that malicious code is running?
tatyana61 [14]

Answer:

If you are running Windows check task manager and see if any background process if running if there is a background process of command prompt or powershell, there is a chance that there is a backdoor running in your system, you can just right click and end the task it should just kick the hacker off the server.

please give brainliest

7 0
3 years ago
In an If-Then-Else statement, the Else clause marks the beginning of the statements to be executed when the Boolean expression i
kari74 [83]

Answer:

False

Explanation:

The definition for the If-Then-Else structure is as follows:

IF (<em>boolean_condition</em>)  

THEN (<em>commands_for_true</em>)  

ELSE (<em>commands_for_false</em>)

When there is an ELSE sentence, its commands are to be executed whenever previous conditions where not evaluated as true .

7 0
3 years ago
Other questions:
  • WILL MARK BRAILIEST IF ANSWERED FAST!!!
    8·1 answer
  • • Describe the steps in detail that the operating system performs to handle interrupts, including ISRs, the stack, and hardware?
    5·1 answer
  • Gathering information with your eyes is called
    13·2 answers
  • In the single-site processing, single-site data (SPSD) scenario, all processing must be done on the end user's side of the syste
    10·2 answers
  • Where are options to add a border around the outside of a chart found?
    9·2 answers
  • Someone pleaseee answer my last question i just posted ;-;
    6·2 answers
  • When using the Simple Query Wizard, Kirsten wanted to transfer all of her available data to a new table. She should click
    14·1 answer
  • How should you best communicate<br> this information to Keisha?<br> (Select all that apply.)
    13·1 answer
  • Consider the following class interfaces:
    8·1 answer
  • _______ is a very common approach to multisystem authorization.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!