CSCI 201 Programming Project 1

Program Description

In this program, you will learn to use integer division and the modulus (or, as the book calls it the remainder) operator. You should write a program named Digits that reads in a single four digit number (like 1998) and then outputs that number one digit per line, like so:
  1
  9
  9
  8
Your prompt should tell the user to enter a four-digit number and you can then assume that the user follows directions. Sample output from your program might look like the following:
Enter a single four-digit integer number: 2003
You entered the number 2003
The digits in that number are:
2
0
0
3
Bye!
You will need to use the Keyboard class to make the job of reading the number easy. To use the Keyboard class, follow these instructions when setting up your netbeans project:
  1. Create a new netbeans project with any name you choose.
  2. Mount the directory where you will store the source code for this program; I'll call this directory your "main project directory".
  3. In the netbeans explorer window, right-click on the directory folder that you just mounted, i.e., your main project directory. In the pop-up window, select New followed by Folder, and then name the folder cs1.
  4. Save the Keyboard class in the newly created cs1 directory.
  5. Now create a new java main class file to contain the source code for your program. Store this file in your main project directory giving it the name Digits.java; the file must be named Digits.java in order to receive full credit for this assignment.
  6. Now to use the Keyboard class in your program (i.e., Digits.java) you simply need to include the following line of code at the start of your program:
      import cs1.Keyboard;
    
    Remember that capitalization is important. There are simple examples of programs that use the Keyboard class in chapter 2 of your text.


Programming Hint: If a variable named number initially stores the value 1998:

Programming Style

Note that 10% of your program grade is based on the readability of your program. This includes things like proper indentation, comments, and the naming of variables and methods as described in the style guide for this class. To receive full credit for your program, make sure that you use proper indentation as demonstrated in your text and in class room examples. Also include comments at the top of each program stating your name, the course, and the purpose of the program: For example:

/*
** Name: your name here 
** 
** Course: CSCI 201 
** 
** Purpose: purpose of program here 
*/

Submitting Programs

The program written for this assignment must be turned in by transferring the java source code file to your ftp directory for this class. Only the source code file (i.e., Digits.java) should be turned in and the file must have exactly that name. You were shown how to transfer files to your class ftp directory in lab 1.