Project 1
Write a Java program to demonstrate using command line arguments to convert numeric quantities with a certain radix (counting base) to base ten numbers. You will employ the use of String methods indexOf()
and substring()
as well as the overloaded Integer
method parseInt()
.
Take a look at the documentation on how to pass command line arguments in Intellij. Other IDEs have similar capabilities.
Learning outcomes
- Working with command line arguments.
- Exposure to rudimentary parsing principles.
- Working with
String
methods. - Working with
Integer.parseInt()
. - Confirmation program produces desired results.
The strings in args
will be the form “value:radix
” where value is expressed with digits appropriate to the radix. So “16384:10
” is 16384
as a base 10
number.
Use indexOf()
to find the colon and gather the number and the radix using substring()
. These values can be used to make a call to parseInt()
to convert the numbers to base 10.
split()
method for this project.If the provided command line arguments were:
4eb:16 10110110:2 407:8 2048:10
Output should be similar to:
4eb base 16 is 1259 base 10 10110110 base 2 is 182 base 10 407 base 8 is 263 base 10 2048 base 10 is 2048 base 10
Submit the project to the Learning Management System as Project1_lastname.java.