1. Base7 (15 points) Given an integer value X, you need to return the base-7 representation...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
1. Base7 (15 points) Given an integer value X, you need to return the base-7 representation of X as a string. In a base-7 representation, each digit is between 0 and 6, both inclusive, and the value of a digit is based on its position in the representation. For example, given a base-7 representation r = (dn...d3d2d1d0)7 (0 d; 6,0 in), the decimal value of r is calculated as d*7 + d3*73 + d2*7 + d*7 + do*7. What to do: In Base7.java [Task 1] Complete method convertToBase7 in class Base7 so that the method will take an int value as the argument and return the argument's String representation based on 7. For example, when the input value is 100, the method should return a string "202". Notes: You may not add new methods to class Base7. You may right-click on class Base7Test and select "Run 'Base7Test" to execute the tests we prepared for class Base7. If any test fails, your implementation is buggy. Note, however, that since the provided tests only check a small number of input/output pairs, passing all those tests does not mean your implementation is correct. package hk.edu.polyu.comp.comp2021.assignment1.base7; import org.junit.Test; import static org.junit.Assert.assertEquals; public class Base7Test { @Test(timeout = 2000) public void test1() { } assertEquals("202", Base7.convertToBase7(num: 100)); @Test(timeout = 2000) public void test2() { } assertEquals("10", Base7.convertToBase7 (num:7)); @Test(timeout = 2000) public void test3() { assertEquals("-24", Base7.convertToBase7 (-18)); } } package hk.edu.polyu.comp.comp2021.assignment1.base7; public class Base7 { public static String convertToBase7(int num) { // Todo: Add your code here return ""; } } 1. Base7 (15 points) Given an integer value X, you need to return the base-7 representation of X as a string. In a base-7 representation, each digit is between 0 and 6, both inclusive, and the value of a digit is based on its position in the representation. For example, given a base-7 representation r = (dn...d3d2d1d0)7 (0 d; 6,0 in), the decimal value of r is calculated as d*7 + d3*73 + d2*7 + d*7 + do*7. What to do: In Base7.java [Task 1] Complete method convertToBase7 in class Base7 so that the method will take an int value as the argument and return the argument's String representation based on 7. For example, when the input value is 100, the method should return a string "202". Notes: You may not add new methods to class Base7. You may right-click on class Base7Test and select "Run 'Base7Test" to execute the tests we prepared for class Base7. If any test fails, your implementation is buggy. Note, however, that since the provided tests only check a small number of input/output pairs, passing all those tests does not mean your implementation is correct. package hk.edu.polyu.comp.comp2021.assignment1.base7; import org.junit.Test; import static org.junit.Assert.assertEquals; public class Base7Test { @Test(timeout = 2000) public void test1() { } assertEquals("202", Base7.convertToBase7(num: 100)); @Test(timeout = 2000) public void test2() { } assertEquals("10", Base7.convertToBase7 (num:7)); @Test(timeout = 2000) public void test3() { assertEquals("-24", Base7.convertToBase7 (-18)); } } package hk.edu.polyu.comp.comp2021.assignment1.base7; public class Base7 { public static String convertToBase7(int num) { // Todo: Add your code here return ""; } }
Expert Answer:
Related Book For
Posted Date:
Students also viewed these programming questions
-
CANMNMM January of this year. (a) Each item will be held in a record. Describe all the data structures that must refer to these records to implement the required functionality. Describe all the...
-
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...
-
What's New 14 el.alphacollege.ca 500 Alpha College E-learning of My Courses Development is informal with a loner-term focus Select one: O True O False Training is formal with a short-term focus....
-
What are the two basic timing strategies? What is the intent of each?
-
Liz Ames owns Fancy Writing Supply Co. in Moncton. As her newly hired accountant, your task is to: a. Journalize the following transactions for the month of May. b. Record in subsidiary ledgers and...
-
A column of intermediate length buckles when the compressive stress is \(40 \mathrm{ksi}\). If the slenderness ratio is 60 , determine the tangent modulus. 5 mm- 200 mm- L
-
The comparative balance sheet of Amelia Enterprises, Inc. at December 31, 2010 and 2009, is as follows: Additional data obtained from the income statement and from an examination of the accounts in...
-
Below is a list of four problem-solving strategies created by Dawn Allison, author of Career Planning and Personal Exploration. These problem-solving strategies can be applied to any aspect of your...
-
A 22.50g of mixture of sand and sodium chloride was mixed with water, heated to 90 celsius and filtered. The student recovered 17.22g of solid precipitate. What was the percent by weight of sodium...
-
What is the difference between arteries and veins structurally?What differences are seen between large and small arteries andlarge and small veins?what do the types of arteries and veins...
-
Every year about 20,000 pounds of stone, sand, and gravel aremined for each person in the United States. Calculate how many pounds of stone, sand, and gravel will beneeded for an individual during an...
-
Elvis Presley died on August 16,1977. He was extremelyoverweight when he died. He had a history of ingesting fatty foodsincluding fried peanut butter and banana sandwiches. He also had along list of...
-
Consider the period 19262014. The geometric mean for the S&P 500 for the entire period was approximately 10 percent and for the CPI, 3.0 percent. Therefore, the real (inflation adjusted) geometric...
-
In September 2011, with the European fiscal crisis regularly in the news, it was reported that Moodys Investors Services was expected to cut the ratings of three large French banks because of their...
-
Two wooden crates with masses as shown are tied together by a horizontal cord. Another cord is tied to the first crate and it is pulled with a force of 192 N at an angle of 20.0, as shown. Each crate...
-
In a nonmagnetic medium, E = 50 cos (10 9 t 8x) a y + 40 sin (10 9 t 8x) a z V/m find the dielectric constant r and the corresponding H.
-
In what sense is the variance (a) A type of mean? (b) Not a readily understood measure of variability? (c) A stepping stone to the standard deviation?
-
Someone claims that, since the mean of the sampling distribution equals the population mean, any single sample mean must also equal the population mean. Any comment?
-
Does the type of instruction in a college sociology class (either lecture or self- paced) and its grading policy (either letter or pass/ fail) influence the performance of students, as measured by...
-
A process has streams to be heated and cooled above its pinch temperatures as illustrated in Figure 11.62. Complete a design that satisfies MER targets with the minimum number of heat exchangers....
-
Consider the network of heat exchangers in Figure 11.60: (a) Determine \(N_{H X, \text { min }}\). (b) Identify the heat loop. (c) Show one way to break the heat loop using \(\Delta T_{\min...
-
To exchange heat between four streams with \(\Delta T_{\text {min }}=20^{\circ} \mathrm{C}\), the HEN in Figure 11.61 is proposed. Determine whether the network has the minimum utility requirements....
Study smarter with the SolutionInn App