Outline
* Administrative Issues / Announcements
* Class Overview
* Homework Help
Administrative Issues / Announcements
Lab Policies
If you want to switch sections, do so on Telebears (or through whatever method you used to enroll); This is the most fair method. If it doesnt work out, you can still switch back to the other section,
We will be more strict on enrollment issues in week two; You may only attend the lab you are registered for.
Somewhere around the end of the second week (or maybe even sooner) we will cancel the account of anyone who is not enrolled (For whatever reason).
You may do the labs on your own time (Either at home or in the lab) and come in just to have them checked off. You may only be checked off in the lab section in which you are enrolled and must be checked off before the end of the section on the day its due. I dont intend to make any special arrangements; You are allowed to drop two lab grades to accomodate special circumstances.
The policies for homework and project submissions are similarly clear. Again, we wont be making any special arrangements, as you have a homework drop and slip days for the projects.
Office Hours
My office hours will be held Tuesdays from 2-3 (Right after this section) and Wednesdays from 10-11, both in 511 Soda.
Newsgroup and Webpage
Please post any course material-related questions to the newsgroup. Not only can your question by answered by either of the TAs or the instructor, but it may also be answered by one of your classmates.
First Week
The first week will be hectic; Thanks for sticking in there.
The homework problem asks you to implement a subtotal calculator using two differnt forms. Here, I have implemented a substring calculator using the same two forms. This is essentially the same thing, but with strings substitued for numbers and concatenation substituted for addition. Here is the code:
public class SubStringConcatA {
public static void main(String[] args)
{
final String FUNCTION_KEY = new String(".");;
System.out.println("SubString Concatenation tool.");
System.out.println("");
System.out.println("Enter one String per line; enter \'" + FUNCTION_KEY +
"\' to indicate the end of a substring group.");
System.out.println("The program will terminate the second time you enter \'" +
FUNCTION_KEY + "\' sequentially.");
String nextLine = new String("");
String fullString = new String("");
String subString = new String("");
// Notice that we use .equals(), which compares the actual characters in each
// String, instead of ==, which compares the references to the String's.
while (!(nextLine.equals(FUNCTION_KEY)))
{
while (!(nextLine.equals(FUNCTION_KEY)))
{
subString = subString + nextLine;
nextLine = readNextLine();
}
System.out.println("Sub String: " + subString);
fullString = fullString + subString;
subString = "";
nextLine = readNextLine();
}
System.out.println("Full String: " + fullString);
}
// This is analogous to nextNumber().
// Dont modify.
public static final String readNextLine()
{
BufferedReader lineReader =
new BufferedReader(new InputStreamReader(System.in));
String nextLine = new String("");
try
{
nextLine = lineReader.readLine();
}
catch (Exception e)
{
System.out.println("Problem");
}
return nextLine;
}
}
import java.io.*;
public class SubStringConcatB {
public static void main(String[] args)
{
final String FUNCTION_KEY = new String(".");
System.out.println("SubString Concatenation tool.");
System.out.println("");
System.out.println("Enter one String per line; enter \'" + FUNCTION_KEY +
"\' to indicate the end of a substring group.");
System.out.println("The program will terminate the second time you enter \'" +
FUNCTION_KEY + "\' sequentially.");
String nextLine = new String("");
String previousLine = new String("");
String fullString = new String("");
String subString = new String("");
// Stop only if both the last line and the current line equal the function key.
// Notice that we use .equals(), which compares the actual characters in each
// String instead of ==, which compares the references to the String's.
while (!(nextLine.equals(FUNCTION_KEY) && previousLine.equals(FUNCTION_KEY)))
{
if (nextLine.equals(FUNCTION_KEY))
{
System.out.println("Sub String: " + subString);
fullString = fullString + subString;
subString = "";
}
else
{
subString = subString + nextLine;
}
previousLine = nextLine;
nextLine = readNextLine();
}
System.out.println("Full String: " + fullString);
}
// This is analogous to nextNumber().
// Dont modify.
public static final String readNextLine()
{
BufferedReader lineReader =
new BufferedReader(new InputStreamReader(System.in));
String nextLine = new String("");
try
{
nextLine = lineReader.readLine();
}
catch (Exception e)
{
System.out.println("Problem");
}
return nextLine;
}
}
Return to the Section 101 Homepage.