Overview
The purpose of this lab is to provide students an opportunity to work closely with algorithms for changing number bases.Content Preparation
- Read Section 1.4 in the textbook.
- Review supplemental videos 2 - 5.
- Write and solve 10 base conversion problems by hand (to make sure you understand the algorithm).
Environment Preparation
This week's lab is to write some Java code. The automated testing for this project uses JUnit 5 and Maven. Make sure you have a suitable environment set up.
The easiest solution may be to use the School of Computing's EOS/Arch environment because they are already set up. This is now even easier because you can work
in EOS/Arch directly through your browser at https://cislab.hpc.gvsu.edu/
. No more x2Go
! This page provides details on how
connect to EOS/Arch through a web browser.
This video discusses the steps below in more detail.
- Follow this GitHubClassroom link to generate your personal repository for next week's lab.
- Clone the generated Git repository.
- Open the project in the IDE of your choice.
- If you use IntelliJ, open it as a "maven" project. not an Eclipse project.
- This knowledge base article explains how to configure Visual Studio Code in the EOS/Arch environment.
- Make sure you can run the JUnit tests. In VS Code, open
BaseConverterStudentTest.java
and look for the green arrows to the left of the code. (The first time you open the project, there may be a delay before they appear.) - Change the
return
statement inBaseConverter::convert
fromreturn ""
toreturn "0"
. Re-run the tests and verify that at least one test now passes. - When you have at least one test passing, commit your changes. (You do this from the command line using
git add .; git commit -m your_message_here; git push
. It is also possible to commit through your IDE.) - After pushing your code, visit your repository's web page and run the automated tests. (This video demonstrates how.)
- From your repository's page, click on the
Actions
tab. - On the left, you should see a list labeled "Workflows". Below that will be "All Workflows", and below that will be "GitHub Classroom Workflow". Select "GitHub Classroom Workflow".
- Selecting "GitHub Classroom Workflow" should cause a banner to appear with a button labeled "Run Workflow" to the right. Open that dropdown menu and click the "Run workflow" button.
- There will be a pause of 10 seconds or so and you will see a yellow dot appear that indicates that your tests are in progress.
- From your repository's page, click on the
Activity
Write a conversion method that will take in a string representing a number in a specified base and convert it to another base. Do not worry so much about catching error conditions; for this lab it is more important to learn the number conversion process and implement the algorithm.
Restrictions:
- This week's lab is an individual assignment.
- Use the provided starter code. Do not change the class name or method signatures.
- You are not allowed to use
Integer.toString(int i, int radix)
,Integer.parseInt(String s, int radix)
or any other library code that completes a significant portion of the assignment. (You may, use the defaultInteger.toString()
for converting a base-10int
to the base-10String
representation of that integer; just don't use a different radix.)
Assumptions:
input
will be a string representing a number in the range of 0 to 231-1base_in
andbase_out
fall between 2 and 36 (inclusive)- For bases over 10, use lowercase letters (Tests will fail and credit not given for uppercase!)
- The return should be a string containing the answer with no leading zeroes.
- Do not worry about illegal input.
Testing:
I have provided a few sample JUnit tests in BaseConverterStudentTest.java
. Add more of your own tests.
I have also written a larger suite of tests that I will use when grading your lab. These tests will run automatically when you push your code. If these tests fail, then you have two problems (1) a bug in your code, and (2) a missing test case (since your test suite didn't find the bug). If your code fails my tests, (1) find the missing test case, (2) fix the corresponding bug, then (3) push the fix. I won't grade your lab until it passes all my tests.
Submission and Grading:
Once your code passes my tests, push the code with the string [Grade Me]
in the commit message.
Updated Tuesday, 7 September 2021, 10:02 AM