CMSC 131 - Fall 2019 - Project #1


Suggested target for Tasks 1&2: before end of office hours Thursday, September 12th.
Suggested target for Task 3: before end of office hours Friday, September 13th.
Suggested target for Task 4: before end of weekend (ie: Sunday, September 15th).
Graded: scan/photo of Task 5 pseudocode/flowchart due on ELMS before 8pm on Tuesday, September 17th.
Suggested target for Task 5: before end of office hours on Wednesday, September 18th.
The project will be due on the Submit Server before 8pm on Friday, September 20th.

Note that for this first project, we are giving a longer late period. The remaining projects will only have a 24-hour late grace period. You should always plan your work around finishing projects a little early so that you do not need to use the late period (which does have a small late penalty). After the late period, no points are granted.

Type of project: CLOSED

Exploring Variables, IO, and Conditional Statements

cat logic

 

Objective

This project will allow you to practice using variables, strings, input/output facilities, conditional statements, logical operators, and the Eclipse IDE.

 

Overview

This project is composed of five tasks. They should be completed in sequential order. The first four are meant to scaffold the ideas we've been seeing in class, leading to the fifth. Each of the tasks will be worth points, so don't skip any. You can upload and test each task as you work on them. Don't worry that the submit server is giving "0" scores for the tasks you have not yet done, the important thing is the score on your last on-time submission. Each task has its own .java file and main method associated with it.

Each task will require you to implement a slightly more advanced application. The first three tasks are to become comfortable with simple IO, variables, comparisons, and conditional statements. The fourth task provides more practice with conditional statements as is meant to have you think about how larger programs that ask you for your language might have to deal with things internally. Finally, the fifth task requires you to implement a short quiz that asks the user to either identify how many BITs are used in certain cryptographic systems or to identify which kind of cryptographic system uses a certain number of bits for their keys.   The quiz questions and answers are already in the starter code you will download. Your code, in the main method, will make use of these. NOTE: During testing, we might change the questions and the answers but if you use the field names rather than the actual stored values in your code, that won't break your program.   While you might not find this the most exciting project, it's a good place to start doing some more involved coding and does incorporate concepts that become important in many projects. Also, if you finish early, you could come up with an idea of a different short program that you could create from scratch in Eclipse and then show your friends.

This project is a closed individual assignment. You may come to office hours to ask us questions of course. Please visit the course web page for information regarding the open/closed policy for projects of this course for more details.


Coding Examples

In addition to the slides on conditional statements, the code examples EvenOddConditional.java and NestedConditional.java and CompoundConditional.java might prove useful to review as you move forward on this project.


Specifications

Task 1
The first program you will write here will prompt the user for an integer and then print out the next integer. To get you started, we've provided the code to display the prompt and read in the number. Your code will go in NextInteger.java in the main method, where indicated. Your task here is to add the appropriate line of code to output a message with the next integer based on the integer that the user enters. For example, if the user enters 9 then your program will print
        The next integer would be 10.

A few quick hints on this task (and others):
  • System.out.println("Hello"+1+1); will print Hello11, but System.out.println("Hello"+(1+1)); will print Hello2
  • the submit server tests look for the exact output, so pay close attention to things like punctuation


Task 2
The next program you will be writing for this project will take two integers as input from the user and then print one of two messages. Your code will go in MaxOfTwoV1.java in the main method, where indicated. The behavior of your code needs to be such that if the first number is greater than the second number, your program will print
        first is greater than second
where first and second are actually the numbers that the user had entered (and they won't appear underlined or bold or italicized). Otherwise, your program will print
        second is greater than or equal to first
again, where first and second are actually the numbers that the user had entered (and they won't appear underlined or bold or italicized).

This is a slightly longer task than the first, but an important step in the progression of the project. Test it out and when you think you've got it all working, upload it and test it out on the submit server.


Task 3
The third program you will be writing for this project will be a little different from the second, and has its own file, MaxOfTwoV2.java where you will add your code. The behavior of this code needs to be such that after taking two integers as input from the user it will then print one of THREE messages; as before if the first number is greater than the second number, your program will print
        first is greater than second
but there's going to be a change for if it isn't. Now, if that first situation wasn't true, you'll need to test to see whether the second number is greater than the first, and if it is your program will print
        second is greater than first
to the output. Finally, if that wasn't true either logic tells us they must actually be equal to each other, so your program will print
        first is equal to second


As with the previous task, this might be short, but is important to become comfortable doing, so test it out locally with a few different values and then upload it and test it out on the submit server.


Task 4
The code for this task will go in MultilingualGreetings.java and be a step above the previous tasks. The program will prompt the user with:
   1) English   2) Espanol   3) Francais:
The user then enters an integer on that same line.

Based on the language selected, you will set the greetingString variable in that language; a 1 means it should be assigned "Hello World!", a 2 means it should be assigned "Hola Mundo!", a 3 means it should be assigned "Bonjour le Monde!", and if the user provided some other integer, that means it should be assigned "###########".

To avoid typos, you should probably copy and paste the above strings into your code as needed. When testing, try multiple possibilities. When you think you've got it all working, test it out on the submit server.


Task 5
Near the top of the file CryptoQuiz.java you'll notice that static variables have been declared and assigned values; NUM_BITS1, NUM_BITS2, NUM_BITS3, CRYPT1, CRYPT2, CRYPT3 before the main method. Within the main method, you will need to add code to implement the quiz. When you need to access one of the question or answer values, use the name of the variable that contains that value. We want you to read the task description carefully, and then draw out your design/implementation ideas in either pseudocode or a flowchart by hand BEFORE you start writing any Java code in Eclipse. It is a good habit to think through your plan first. It also should prepare you for your written exams, where you will not have a computer in front of you. This hand-written document is what you will scan or take a photo of to upload to ELMS.

The first question the user will see is:
    Enter 1 to guess a cryptographic system, 2 to guess how many BITs:

The user then enters either 1 or 2.

Processing a choice of 1
The program prompts the user with:
   Choose number of BITs:

The user must enter either 80, 128, or 168.  If any other number is entered, the program will print out "Invalid choice." and will terminate with no further input or output.

Assuming that the user has entered one of the three valid numbers, the program prompts the user with either:
   Which cryptographic system uses n BITs?
Please note that the n must actually be either 80, 128, or 168  depending on what the user has selected, and appears as regular text rather than bold and italicized.

The user will need to enter a String.  If the String entered represents the correct cryptographic system for the number of BITs selected, the program will output "Correct!" and then terminate normally.  However, if the user has entered the incorrect String, then the program will output "Incorrect!" and then terminate normally.

Processing an Entry of "2"
The program prompts the user with:
   Choose a cryptographic system:

The user must enter either "Skipjack", "Rijndael", or "TripleDES".  If any other String is entered, the program will print out "Invalid choice." and will terminate with no further input or output.

Assuming that the user has entered one of the three valid cryptographic systems, the program prompts the user with either:
   How many BITs used in a CRYPT system?

Again, in the prompt above, CRYPT must actually be either "Skipjack", "Rijndael", or "TripleDES"  depending on what the user has selected, and appears as regular text rather than bold and italicized.

The user will enter a number.  If the value entered represents the correct number of BITs for the cryptographic system selected, the program will output "Correct!" and then terminate normally.  However, if the user has entered the incorrect value, then the program will output "Incorrect!" and then terminate normally.


Getting Started

In order to help you get started, for each task we have created a different .java file in which you will work, and each has a main( ) method in that file. All of these files can be retrieved at once by checking out the project from the CVS repository. Remember that you must have set up your repository in order to check out and submit projects.  Start by going to your CVS repository and checking out project Fall2019-Proj1. After checking out the project, when you switch back to the Java perspective, you will see the above files in the "Package Explorer" window, and you will be able to start modifying them.

If you write the project from scratch, without checking out the "Fall2019-Proj1" files from your CVS repository, you will NOT be able to submit your work and you will NOT get credit for it.

 

Requirements

 

Sample Runs

The following examples show how your program should behave.  Note that for the Task 5 examples, items in italics represent the things that are entered by the user.  Keep in mind these are just examples and NOT the only scenarios that your program is expected to handle. You should test many different input scenarios.

Task 1 Example
The user is prompted with: Please enter an integer:
The user enters:  9
The output is:    The next integer would be 10.

Task 2 Example
The user enters:  10 20
The output is:    20 is greater than or equal to 10

Task 3 Example
The user enters:  10 20
The output is:    20 is greater than 10

Task 4 Example
The user is prompted with: 1) English   2) Espanol   3) Francais:
The user enters:  1
The output is:    Hello World!

Task 5 Example 1
For these Task 5 examples we are showing what a full run looks like in the command window.
Enter 1 to guess a cryptographic system, 2 to guess how many BITs: 1
Choose number of BITs: 3
Invalid choice.

Task 5 Example 2
For these Task 5 examples we are showing what a full run looks like in the command window.
Enter 1 to guess a cryptographic system, 2 to guess how many BITs: 1
Choose number of BITs: 128
Which cryptographic system uses 128 BITs? Skipjack
Incorrect!


Pseudocode/Flowchart

The scan/photo of pseudocode/flowchart assignment for this project is associated with Task 5. After reading the description for the task, draw out your design/implementation ideas in either pseudocode or a flowchart by hand and then upload a scan or photo of that to ELMS before 8pm on Tuesday, September 19th. It can be a jpg, gif, or pdf file. This will be worth 10% of your project grade. Please note your pseudocode/flowchart doesn't have to be perfect to get full credit, it just needs to reflect that you have read the description and have thought about the structure of the Java code you will be writing.


CVS Reminder

Please note that you will use the CVS repository to check out the starter files for the project but should also use it as a way to keep regular backups of your code.

To commit changes that you have made to a Java project in Eclipse, right-click on the project name in the Package Explorer pane, then go to the Team submenu, and then select Commit... from there. Each time you commit changes, the modifications since the last time you made a commit will be stored in your CVS repository. We will see how this not only creates an external backup of your work, but can be used to view earlier versions of your own code. This provides several advantages, including that if something goes wrong with your computer and you have to use another one, you can pull a very recent version of your work from which to resume (and then be sure to commit your new version of course).


Project Submission

Submit your project from Eclipse by right-clicking the project folder and selecting "Submit Project".  You are encouraged to submit as you complete each task (or think you have completed it). This means you have run the program for a task and tested it out yourself and think it's ready to pass our tests. We we only grade your most recent submission (before the deadline) so there's no penalty for mistakes the submit server reveals if you then fix them before the due date. After you have submitted a version of your project, you then need to visit the submit server to obtain (limited) feedback about how well your project is performing. (Choose "release test" to see detailed information.) While the public tests can be run as often as needed (within logistical reason of course) the number of times you can run our release tests on your project (before the due date) is limited so the earlier you begin working on the project, the more opportunities you will have to see how your project performs on our tests before the due date!

 

Grading

There are eleven public and eight release tests which will be run on your project. Different tests will be worth different amounts of points. Some tests will test not only what your program does, but how it does it. Please note that some of the release tests will test multiple scenarios within them and will not have partial credit within that test. Together, these tests will determine 90% of the grade on the project. 





Web Accessibility