Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 5 . Return the difference in times as a percentage Write a method that takes two values that represent elapsed time as arguments, finds

15. Return the difference in times as a percentage
Write a method that takes two values that represent elapsed time as arguments, finds the larger one, calculates the percent difference, and returns a message as a string. As we are somewhat interested in precision, you should think about how to make sure the percentages contain decimal places.
You should have noticed that the time increased as a square of the number of elements. This is notated as O(n^2). Those results, as raw numbers, may be hard to interpret.
In this question you will write a method that takes two values that represent elapsed time as arguments, finds the larger one, calculates the percent difference, and returns a message as a string. As we are somewhat interested in precision, you should think about how to make sure the percentages contain decimal places.
Your output should look like one of the following for the appropriate case:
"Value 1 is n% bigger than Value 2."
"Value 2 is n% bigger than Value 1."
"The two values are equal."
Tip:
In reality you would most likely avoid composing the message in your percentage method and would just return the percentage as an integer. This question is constructed such that you should not modify the main method.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions