|
midterm
Nov 10, 2001 8:58:39 GMT -5
Post by pandachan on Nov 10, 2001 8:58:39 GMT -5
I was reading the news group and find the email that says, there is one more midterm coming. Is that true?
|
|
|
midterm
Nov 10, 2001 12:38:22 GMT -5
Post by Majin_Blues on Nov 10, 2001 12:38:22 GMT -5
yes... there's one this week...
|
|
|
midterm
Nov 10, 2001 16:44:51 GMT -5
Post by Brutal_Chicken on Nov 10, 2001 16:44:51 GMT -5
Question: what is the coverage for you guys on this midterm? Mine is up to and including 2d arrays. I heard for some they stop at the recursive loops.
|
|
|
midterm
Nov 10, 2001 19:45:17 GMT -5
Post by kermit on Nov 10, 2001 19:45:17 GMT -5
Question: what is the coverage for you guys on this midterm? Mine is up to and including 2d arrays. I heard for some they stop at the recursive loops. well, prof Carter said we need to know these things for the test: -toString -loops - while, do, for -arrays -->and marks may be deducted for style. in class, we learned up to 3d arrays, but i'm not sure if those are going to be on the test...i'm going to study those anyway, just in case.
|
|
|
midterm
Nov 10, 2001 21:17:32 GMT -5
Post by Brutal_Chicken on Nov 10, 2001 21:17:32 GMT -5
Well, I think they might teach at different paces but the coverage should be somewhat similar for all of us. I'm betting 1d arrays would be on it or maybe up to 3d but just declaration/initialization.
Guess, we'll hafta wait and see.
|
|
|
midterm
Nov 11, 2001 11:13:21 GMT -5
Post by bladehunter on Nov 11, 2001 11:13:21 GMT -5
For Prof. Clarke's class, we have our test just to loops.
Just like our last test, 2 questions; 1 program q and another crazy question involving loops.
I believe the crazy question is a trace-what-happens kind of question. I might be wrong.
|
|
|
midterm
Nov 11, 2001 23:29:10 GMT -5
Post by R on Nov 11, 2001 23:29:10 GMT -5
My prof is pacheceo, we never learned "do" for loops...
also, anyone have any old midterms?
|
|
|
midterm
Nov 12, 2001 17:11:53 GMT -5
Post by Brutal_Chicken on Nov 12, 2001 17:11:53 GMT -5
Reading the newsgroup one of the TAs said that the best way to study for midterms (referring to this one, I believe) is to dream up questions similar to Assignment 6. You know, the one that had you pulling out your hair due to its ambiguity. I'm gonna sit here and wait till you're finished cursing. Don't worry, I'm not going anywhere. Back yet? Good.
Now, here's a text copy of the winter 2000 midterm.
University of Toronto 1 Department of Computer Science name: 2 CSC 108H1S — Winter 2000 Total Midterm test student number: (J. Clarke’s section) Aids allowed: Textbook, API ref.
Time: 50 minutes 1. [10 marks]
(a) Below is the beginning of a program that reads a sequence of positive numbers and prints the largest one. You are to complete the program.
You may assume:
There is at least one positive number in the input. All the input numbers are positive, except the last, which is 0, as mentioned in the next point. The sequence of input numbers is ended by a 0, which is not part of the sequence. (The number 0 is not positive.) import java.io.*; public class Q1a { public static void main (String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
// You write the rest.
(b) This part is like part (a), except that:
You are to find the smallest positive number in the input (not the largest). There is no guarantee that there is even one positive number in the input before the concluding 0. If there are none, your program should print "No positive numbers read". There may be negative numbers in the input sequence. These are to be ignored. import java.io.*; public class Q1a { public static void main (String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
// You write the rest.
2. [10 marks]
The complete form of the program shown below prints this output:
This taxi's amount earned: 8.75 Zenobia has $8.7 left. Yvan has $4.5 left.
Here is the program, but it is not complete. Replace the upper-case (capitalized) comments with appropriate code. Do not add any code that is not specified in the comments.
public class Q2 { public static void main (String[] args) { Taxi theTaxi = new Taxi(); Passenger p1 = new Passenger("Zenobia", 1.5, 12.45); Passenger p2 = new Passenger("Yvan", 2.0, 9.50); theTaxi.carry(p1); theTaxi.carry(p2); System.out.println(theTaxi); System.out.println(p1); System.out.println(p2); } } class Taxi { private static double COST_PER_KM = 2.50; // dollars private double amountEarned = 0; public void carry (Passenger p) { // SUPPLY THE BODY OF THIS METHOD.
} // WRITE A toString() method here.
} // end of the Taxi class class Passenger { private String name; private double distance; // in km private double moneyLeft; // in dollars // WRITE A CONSTRUCTOR HERE.
public double getDistance () { return distance; } public void beCharged (double howMuch) { moneyLeft -= howMuch;} // WRITE A toString() method here.
} // end of the Passenger class
|
|
|
midterm
Nov 12, 2001 17:14:28 GMT -5
Post by Brutal_Chicken on Nov 12, 2001 17:14:28 GMT -5
Give up? Here are the answers;
import java.io.*;
// Question 1, part (a)
public class Q1a { public static void main (String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int biggest = 0; while (true) { System.out.print("? "); System.out.flush(); int newNumber = Integer.parseInt(in.readLine()); if (newNumber == 0) break; if (newNumber > biggest) biggest = newNumber; } System.out.println("Biggest was " + biggest); } }
import java.io.*;
// Question 1, part (b)
public class Q1b { public static void main (String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int smallest = 0; // Java insists on the initialization. boolean numberRead = false; while (true) { System.out.print("? "); System.out.flush(); int newNumber = Integer.parseInt(in.readLine()); if (newNumber == 0) break; if (newNumber > 0 && (! numberRead || newNumber < smallest)) { numberRead = true; smallest = newNumber; } } if (numberRead) System.out.println("Smallest was " + smallest); else System.out.println("No positive numbers read"); } }
// Question 2
class Taxi { private static double COST_PER_KM = 0.80; // dollars private double amountEarned = 0; public void carry (Passenger p) { double fare = p.getDistance() * COST_PER_KM; amountEarned += fare; p.beCharged(fare); } public String toString () { return "This taxi's amount earned: " + amountEarned; } }
class Passenger { private String name; private double distance; // in km private double moneyLeft; // in dollars public Passenger (String who, double howFar, double cash) { name = who; distance = howFar; moneyLeft = cash; } public double getDistance () { return distance; } public void beCharged (double howMuch) { moneyLeft -= howMuch;} public String toString () { return name + " has $" + moneyLeft + " left."; } }
public class Q2 { public static void main (String[] args) { Taxi theTaxi = new Taxi(); Passenger p1 = new Passenger("Zenobia", 1.5, 12.45); Passenger p2 = new Passenger("Yvan", 2.0, 9.50); theTaxi.carry(p1); theTaxi.carry(p2); System.out.println(theTaxi); System.out.println(p1); System.out.println(p2); } }
|
|
|
midterm
Nov 12, 2001 17:35:42 GMT -5
Post by bladehunter on Nov 12, 2001 17:35:42 GMT -5
;D
Thank God i had the test today. I wish all those who have the comp. sci. test with the STA107 test on wed. a good luck.
|
|
|
midterm
Nov 12, 2001 22:05:05 GMT -5
Post by TheRock on Nov 12, 2001 22:05:05 GMT -5
can someone tell me what is "System.out.flush()"? I never learned it in my lecture.............
|
|
|
midterm
Nov 13, 2001 14:08:46 GMT -5
Post by Sylph on Nov 13, 2001 14:08:46 GMT -5
Brutal_Chicken, where did u get that midterm from?
|
|
|
midterm
Nov 13, 2001 18:07:11 GMT -5
Post by Sylph on Nov 13, 2001 18:07:11 GMT -5
argh! Brutal_Chicken... that midterm u posted... i tried to do 1a, and i didn't even know how. i was thinking arrays, and then i realized it wouldn't work, and then i thought of vectors, but we're only starting to learn that. so i just looked at the answer. but i didn't even learn that stuff! what's flush? what's break? my prof discouraged us from learning about break... this is so depressing!
|
|
|
midterm
Nov 13, 2001 19:05:46 GMT -5
Post by Brutal_Chicken on Nov 13, 2001 19:05:46 GMT -5
Calm down man. It's only a guide; sometimes things are in it that weren't covered sometimes not. I'm pretty sure we didn't learn about flush and break depends on the prof's preferrences. That flush stuff is just a fancy output anyways so no worries, mate.
Calm down, relax. 8)
|
|
|
midterm
Nov 13, 2001 19:39:21 GMT -5
Post by SquirrelHunterPro on Nov 13, 2001 19:39:21 GMT -5
ARGH! everyone can just bite my nuts... I got plenty stored up for winter... i just got my second 4/20 on problem sets..... and getting a freakin 57% on the midterm doesnt make me feel any fresher... Now I gotta do 2 tests tommorrow, I have no idea what is on the stats test and comp sci test that chicken posted up looked like shit grafitti... makes no sense...and talking of shit, what the hell is System.out.flush?
|
|