| CS 455/555 - Intro to Networks and Communications
Fall 2009: Tues/Thurs 3-4:15pm, Spong 0108 |
|
Staff
Syllabus (pdf) |
Program 1: Java RefresherAssigned: Tues, Sep 1, 2009
MotivationWe will be using Java for programming assignments throughout the semester. It is assumed that you already know Java or feel comfortable enough in your programming skills to be able to learn enough Java to complete the assignments. The reason we are using Java is that the socket programming constructs used to develop network applications are much simpler in Java than in C or C++. If you cannot complete this assignment in just a few (2-4) hours, please come talk to me. DescriptionTask 1: Read in the command-line arguments. The program should take 3 command-line arguments:
Usage: java Prog1 URL integer .TLD
ERR - URL format
ERR - arg 2
ERR - TLD format
Task 2: Output the number of characters in the URL after
Task 3: Output the product of the number calculated in Task 2 and the integer command-line argument
Task 4: Determine if the hostname in the URL ends in the TLD
ERR - hostname format
YES
NO
For this assignment, valid URLs will be written in the form Rules
TestingA large part of your program's grade will be determined by how well it handles a set of inputs. You should test your program rigorously before submitting. Because your programs will be run and tested using a script, you must format your output exactly as I have described or you will lose points. Example 1 java Prog1 Usage: java Prog1 URL integer .TLD Example 2 java Prog1 http://amazon.com 3 .com 10 30 YES Example 3 java Prog1 http://amazon.edu.com 5 .edu 14 70 NO Example 4 java Prog1 http://www.amazon.com/myaccount.html 5 .com 29 145 YES Example 5 java Prog1 ftp://amazon.com 4 .edu ERR - URL format Example 6 java Prog1 http://amazon/banana.html 5 .com 18 90 ERR - hostname format SubmissionYou must name your source file Prog1.java (capitalize only the first letter). Make sure that you submit all files necessary to compile your program. But, do not submit compiled files (.class files). Directions for submitting your assignment through Blackboard Getting Started with JavaIf you've never programmed with Java before, here are a couple of helpful hints:
Here is the skeleton for Program 1 (to be saved as Prog1.java):
// Insert Your Name
// Insert Your Class (CS 455 or CS 555), Fall 2009
// Program 1 - Java Refresher
import java.io.*;
class Prog1 {
public static void main (String argv[])
{
// insert your code here
}
}
|