CS 1713 Introduction to Computer Science, Fall 2009 Exam 1 Comments
The exam average was xx.
If you got below 80, you need to review some more.
If you got below 60, you are not prepared to continue with this course.
- You were not asked to initialize the variables or to print anything out.
- Here, you need to avoid integer division. Cast the numerator or
denominator to a double.
- The key here is integer division and the fact that division is not
associative: It is not always true that (x/y) + (z/y) = (x+z)/y.
- Note that there are 4 possible values, so you should use rand.nextInt(4).
- You need to use .equals to compare String.
You need to use an if-else since you always want to print something,
even if the names are different.
- In Java, you never have to write if(xxx==true). You can just use if(xxx).
The following are all different:
10 cent per gallon discount: totalPrice = 3.59*gallons;
10 per cent discount: totalPrice = .9*3.69*gallons; (5 students)
90 per cent discount: totalPrice = .1*3.69*gallons; (3 students)
91 per cent discount: totalPrice = .09*3.69*gallons; (2 students)
$10 discount per gallon: totalPrice = 3.69*gallons - 10*gallons (2 students)
90 cents per gallon gas: totalPrice = 0.9*gallons (1 student)
- If the condition is false, your program segment should not do anything.
- You need to print a message no matter what the value of numSold is.
- This is almost the same as the previous problem.
- You must prompt inside the loop before you read in a value.
- Do not put the System.out.println inside the loop
- A number of people did not understand the concept of square root.
- The project is really due on Monday!