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....
-
Assume Rafael can earn an 8 percent after-tax rate of return. Would he prefer $1,000 today or $1,500 in five years?
-
A box containing 500 smart phones has 20 defective phones. If 10 phones are selected together from the box, what is the probability that (a) All 10 are defective? (b) None is defective? (c) Half of...
-
Reconsider Problem 56. Determine which oven should be purchased based on an incremental annual worth analysis. Data from problem 56 Octavia Bakery is planning to purchase one of two ovens. The...
-
Businesses incur various costs in selling goods and services. Each business must decide which costs are expenses of the period and which should be included in the cost of the inventory. The following...
-
A 1 kg metal block is heated to 200 C and then dropped into a thermally isolated container with 4 kg of water and 100 gr of ice both at a temperature of 0 C. If the specific heat of water is cw=4186...
-
Consider the equation below. f(x) = 4x + 6x 24x + 2 %3D A) Find the interval on which f is increasing. (Give your answer using interval notation.) B) Find the intervals on which f is decreasing....
-
Imagine that you and several of your classmates have bought the patents and production facilities of a US motor scooter company that has gone bankrupt. Given the growing market for home deliveries,...
-
You have recently been appointed as a senior advisor in the domestic and overseas trade division in your countrys ministry of trade and development. Despite a high birth rate and a good education...
-
You are the CEO of a major clothing manufacturer based just outside Manila, Philippines. Over 80 percent of your output sees you operating as a third-party manufacturer for several global brands. All...
-
Refer to question 1-34. Suppose, instead, that you were considering opening a factory and sales office in Bejing, China. What questions would you want answered before proceeding with this idea? How...
-
You are the CEO of a Japanese importer that resells designer bags, purses, and wallets across Southeast Asia. Many of the products are manufactured in Southeast Asia, mainly Vietnam, Indonesia, and...
-
If an investor is interested in the solvency of a company, he/she should analyze the: balance sheet and income statement. income statement, balance sheet, and statement of cash flows. balance sheet...
-
a) Show that (a, b) := {{a}, {b}} does not satisfy the ordered pair axiom. b) Determine whether each of the following statements is true or false. (Give a reason in each case): (i) {a, b} C (a, b)....
-
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...
-
The data in Table 2 represent the results of a survey in which 200 people were asked their means of travel to work. (a) Use the survey data to build a probability model for means of travel to work....
-
Sophia has three tickets to a concert, but Yolanda, Michael, Kevin, and Marissa all want to go to the concert with her. To be fair, Sophia randomly selects the two people who can go with her. (a)...
-
Suppose that a survey asked 500 families with three children to disclose the gender of their children and found that 180 of the families had two boys and one girl. (a) Estimate the probability of...
Study smarter with the SolutionInn App