August 29, 2017
What println statements will generate the following output?
This program prints a
quote from the Gettysburg Address.
"Four score and seven years ago,
our 'fore fathers' brought forth on
this continent a new nation."What println statements will generate the following output?
A "quoted" String is
'much' better if you learn
the rules of "escape sequences."
Also, "" represents an empty String.
Don't forget: use \" instead of " !
'' is not the same as "August 31, 2017
September 7, 2017
Write a for-loop that will produce the following output:
System.out.println("1 squared = " + 1 * 1);
System.out.println("2 squared = " + 2 * 2);
System.out.println("3 squared = " + 3 * 3);
System.out.println("4 squared = " + 4 * 4);
System.out.println("5 squared = " + 5 * 5);
System.out.println("6 squared = " + 6 * 6);September 14, 2017
September 19, 2017
Write the following methods (the first two are required and collected on Tuesday). Follow the template:
public static /* <<return type>> */ methodName ( /* <<parameters>> */ ) {
/* code goes here */
return /* return value */;
}
countQuarters that takes an int number of cents and returns the number of quarters represented by that many cents. Don’t count dollars, as those will be dispensed as dollar bills.countQuarters(83) returns 3countQuarters(1256) returns 2distance that takes four int coordinates (x1, y1, x2, y2) and returns the distance between themdistance(1, 2, 4, 6) returns 5.0calcArea that accepts a circle's radius as a double parameter and returns its area. HINT: use the constant Math.PIcalcDistanceFromOrigin that accepts x and y coordinates as double parameters and returns the distance between the point (x,y) and the origin (0,0).calcAttendancePoints that accepts an integral number of lectures attended by a student, and returns how many points a student receives for attendance. The student receives 2 points for each of the first 5 lectures and 1 point for each subsequent lecture.September 26, 2017
September 28, 2017
October 5, 2017
October 12, 2017
October 17, 2017
October 19, 2017
October 24, 2017
October 26, 2017
October 31, 2017
November 2, 2017
November 7, 2017
public static boolean ends(String s1, String s2) {
return s1.length() >= 2 && s2.length() >= 2 && s1.endsWith(s2.substring(s2.length() - 2));
}
public static boolean pickSeven(Random r) {
for (int i = 0; i < 10; i++) {
int number = r.nextInt(30) + 1;
System.out.print(number + " ");
if (number == 7) {
return true;
}
}
return false;
}
public static int sumDigits(int number) {
int sum = 0;
while (number != 0) {
int digit = number % 10;
sum += digit;
number /= 10;
}
return sum;
}
November 9, 2017
Guest Lecture by Dr. Zoppetti
November 16, 2017
November 21, 2017
November 28, 2017
November 30, 2017
December 5, 2017
December 7, 2017