Due Day, Month Date at 12:00 pm
This assignment must be completed individually. Working in groups is not permitted
This assignment is intended to lightly access your programming skills while making sure everyone has a working IDE (IntelliJ) and JDK installation on a machine they have access to. Keep in mind this projects can be done on repl.it but is it highly recommended that you get a proper machine to work on, as it is a more professional environment and offers access to professional tools to help you develop, debug and implement your solution.
Assignment Logistics
Starter Files
You are provided a GitHub starting code base. Part of the purpose of this project is to get you acclimated to cloning code bases and submitting code via GitHub. You will be walked through this process in Part 1 of this programming project.
Resources
Check out the Oracle style guide for a guide on how you should be formatting your code.
Academic Honesty and Getting Help
Students are expected to maintain academic honesty in all aspects of their programming work. While seeking assistance or clarification on general computer science concepts or programming languages is acceptable and even encouraged (via the forums here), students must refrain from seeking specific help on programming projects or assignments from sources other than their instructors or teaching assistants.
This means that students may ask general questions related to programming languages, data structures, algorithms, and other topics related to computer science. However, they should not seek specific help or guidance on their programming projects from other students, online resources, or any other sources that are not approved by the instructor.
Students must always ensure that their programming work is their own and does not involve any form of plagiarism, cheating, or academic dishonesty. Any violation of these academic honesty rules will be dealt with severely, including a failing grade on the project and may include additional disciplinary actions.
In summary, students are encouraged to seek help and guidance from their instructors and/or teaching assistants, but they should not seek help on specific programming projects or assignments from unauthorized sources. Maintaining academic honesty is essential to learning and the integrity of the academic community.
Part One: Create a GitHub Account
GitHub is a code hosting platform for version control and collaboration. It lets you and others work together on projects from anywhere. In this class, you will be using GitHub to submit all of your programming projects. Create an account using your Damien issued email address at https://github.com/signup. Choose a username that uniquely identifies you that includes your last name. Go through the rest of the process (don’t worry too much about some of the settings, you are new to this and are not expected to understand it all) by choosing default options and a free account.
Background: What is a VCS?
GitHub is a VCS or a Version Control System. Git is a distributed version control system that tracks changes in any set of computer files, usually used for coordinating work among programmers collaboratively developing source code during software development. It allows programmers to download code, submit changes to code, and roll back to a previous version in the case of errors (among other things).
Background: What is a Repository?
GitHub is a VCS or a Version Control System. Git is a distributed version control system that tracks changes in any set of computer files, usually used for coordinating work among programmers collaboratively developing source code during software development. It allows programmers to download code, submit changes to code, and roll back to a previous version in the case of errors (among other things).
Background: Cloning a Repository.
VCS systems like GitHub support the cloning of repositories. Cloning a repository is the process of grabbing all the code, documentation, libraries, resources, setup files, etc. from online to a local machine so that you can work on the project.
Milestone One: Accept the Assignment via GitHub and Get Your IDE Going
After you have created your GitHub account, navigate to https://classroom.github.com/a/7prtLy_Q and accept the assignment. You may have to select and link to your name this time (since you are joining an official GitHub Classroom), but will not have to repeat this process in the future. Finally, click on the “Accept this assignment” button to create a repository and add the starting code base.
This process will ultimately create a repository for you that is linked with this programming project for the purpose of downloading the starting code base and submitting your completed project.
We now need to bring in the starting code base for this project into IntelliJ so that we can start coding. Watch this video for a walkthrough on how to clone a GitHub repository to a local machine via IntelliJ.
Once done, you should have the starting code base (it’s not much this time, just a Main.java class, main method and a Scanner declaration) in IntelliJ. Run the code and you should see no errors (although no output is produced either). We are now ready to code!
Milestone One Requirements
- Create a GitHub student account.
- Join the GitHub Classroom.
- Clone the project from GitHub into the IntelliJ IDE on your local machine.
Some Notes on this problem:
- Start Early! There are a lot of problems you may encounter when first trying to setup a working environment on your machine. Starting early gives you the time to struggle, make mistakes and most importantly, get help. If you wait to the last minute you may find yourself in a situation that is not quickly fixable, pushing back your project and ultimately costing you points.
- It’s normal to feel a bit overwhelmed and confused when you first start programming. There’s a lot to worry about: setting up the required software, linking libraries and languages, using VCS’s, and programming the solution, among other things. Don’t struggle in silence, use the forums to seek help and advice. There is help just around the corner, you just need the courage and initiative to ask!
Part Two: Separate a 5-Digit Number
This project requires you to read in a 5-digit integer from the user, via the Scanner object, and separate it using mathematical expressions into the
- One’s Digit
- Ten’s Digit
- Hundred’s Digit
- Thousand’s Digit
- Ten-Thousands Digit
For example, suppose the user typed in the number
83626
The number should be split up (using mathematical expressions) into:
6 //The ones digit
2 //The tens digit
6 //The hundreds digit
3 //The thousands digit
8 //The ten-thousands digit
Background: Integer Division
Java handles integer division a little differently than you may be used to from your standard math class. In Java, an integer divided by an integer will always result in an integer. The result is always truncated, meaning the decimal portion of the answer is “chopped off”, no rounding occurs. See below for examples of Java integer division:
10 / 2 = 5
10 / 3 = 3
15 / 4 = 3
21 / 5 = 4
9 / 2 = 4
You will need to harness this ability in order to complete this project.
Background: The Modulus Operator
Java also has a new mathematical operator that you may not be familiar with: The modulus operator (%). The modulus operator is used to find the integer remainder after division. See below for examples of Java modulus expressions and their results.
10 % 3 = 1
10 % 5 = 0
15 % 4 = 3
3 % 10 = 3
The modulus operator can be used in conjunction with the way Java handles integer division to get a perfectly precise answer. For example:
10 / 3 = 3
10 % 3 = 1
Gives us the precise answer to 10/3. That is, 10/3 is 3 with a remainder of 1. That result is much more precise than 10.33333333333333.
You must use the modulus operator in order to complete this project.
Milestone Two: Read in an Integer and Output It’s Value
The ability to break down a complex problem into smaller, more manageable parts is crucial and highly beneficial. This skill is commonly known as abstraction or functional decomposition in the field of programming. Milestone Two is simple: read in a five-digit number using a Scanner object and output it back onto the screen. This is overly simple but will train you to begin thinking about larger problems in smaller pieces in the future. Once you are done coding your output should look like the following (assuming the user enters 18372):
Enter a 5-digit integer: 18372
You entered 18372
Milestone Two Requirements
- Use method nextInt() from class Scanner and store the user input in an integer variable.
- Using a println statement, output the required String, “You entered “, concatenated with the integer variable where you are storing the user input.
This is a simple step but make sure to pay attention to the details. Your output should look exactly like the sample output (again, assuming they enter 18372). Match spacing, new lines, etc. to ensure your output matches the example.
Some Notes on this problem:
- After completing this Milestone, you are about 50% done with the project. keep going!
- There is a way to “cheat” the requirements of this project by using Strings instead on integers, you may even find this is the recommended way to achieve these results if you search online for help. You may not use String variables to solve this project, you must use integer variables.
Milestone Three: Use Mathematical Expression to Separate the 5-digit Number
Now, we need to create mathematical expressions that operate on our 5-digit number to “separate” each digit. You will achieve this through using integer division and the modulus operator. Finally, you will print out each digit onto the console. Your output must match, exactly, the example below (assuming the integer 73803 was entered):
Enter a 5-digit integer: 73803
The ones digit is: 3
The tens digit is: 0
The hundreds digit is: 8
The thousands digit is: 3
The ten-thousands digit is: 7
Notice that this output does not include Milestone One’s output “You entered ” with the number. You need to comment this line of code to remove it from execution. Please do not delete this line of code as it needs to appear in your submission for credit.
Milestone Three Requirements
- Use mathematical expressions including division and modulus to separate out each digit. Store each digit in its own integer variable. Make sure you use meaningful variable names or points will be deducted.
- Use println statements and String concatenation to print out the required output.
Your output should look exactly like the sample output (again, assuming they enter 73803). Match spacing, new lines, etc. to ensure your output matches the example.
Submission Instructions
Before you call it done, run through the submit checklist to be sure all your t’s are crossed and i’s are dotted. Make sure your code follows Oracle’s style guide. Then commit and push your code to GitHub.
And that’s it! You’re done!