Foothill Community College Online Portfolio
CIS27A Beginning Java Programming
Text Version of quiz results with some graded quizzes

Quiz #1 Student ID: bouyssounouse6788 (Bouyssounouse_Janine) Time Stamp: Date: 6/29/2004, Time: 9:02 PM ---------------- Elapsed Time: 7 minutes Answers submitted by Bouyssounouse_Janine: --------- 1. a --------- 2. c e --------- 3. c --------- 4. b d --------- 5. b --------- ---------------- The correct answers: --------- 1. a --------- 2. c e --------- 3. c --------- 4. b d --------- 5. b --------- ---------------- Comments on Bouyssounouse_Janine's test: 1. CORRECT. 2. CORRECT. 3. CORRECT. 4. CORRECT. 5. CORRECT. ---------------- Total Possible: 5 Calculated points for Bouyssounouse_Janine: 5 Quiz #2 Student ID: bouyssounouse6788 (Bouyssounouse_Janine) Time Stamp: Date: 6/29/2004, Time: 9:15 PM ---------------- Elapsed Time: 6 minutes Answers submitted by Bouyssounouse_Janine: --------- 1. b c --------- 2. b --------- 3. c --------- 4. b d --------- 5. d --------- ---------------- The correct answers: --------- 1. b --------- 2. b --------- 3. c --------- 4. b d --------- 5. d --------- ---------------- Comments on Bouyssounouse_Janine's test: 1. (-1) The reason c shouldn't be checked is as follows: An int can not have a decimal point 2. CORRECT. 3. CORRECT. 4. CORRECT. 5. CORRECT. ---------------- Total Possible: 5 Calculated points for Bouyssounouse_Janine: 4 Quiz #3 ***************************************** Student ID: bouyssounouse6788 (Bouyssounouse_Janine) Time Stamp: Date: 7/10/2004, Time: 6:23 PM ---------------- Elapsed Time: 8 minutes Answers submitted by Bouyssounouse_Janine: 1. d ----------------- 2. b ----------------- 3. d ----------------- 4. c ----------------- 5. c -----------------  The correct answers: 1. d ----------------- 2. b ----------------- 3. d ----------------- 4. c ----------------- 5. c -----------------  Comments on Bouyssounouse_Janine's test: 1. CORRECT. 2. CORRECT. 3. CORRECT. 4. CORRECT. 5. CORRECT. ---------------- Total Possible: 5 Your Score: 5 Your submission has been received. ***************************************** Midterm Student ID: bouyssounouse6788 (Bouyssounouse_Janine) Time Stamp: Date: 7/14/2004, Time: 8:11 PM ---------------- Elapsed Time: 105 minutes Answers submitted by Bouyssounouse_Janine: --------- 1. c --------- 2. b --------- 3. c --------- 4. d --------- 5. b --------- 6. b --------- 7. c --------- 8. a --------- 9. d --------- 10. d --------- 11. /** This class accepts input for a name of an inventory item and the count of the inventory item. It also adds and takes away from the inventory count. @author Janine Bouyssounouse */ public class InventoryItem { /** Constructs a default InventoryItem */ public InventoryItem() { name = "no name"; count = 0; } /** Constructs an InventoryItem @param aName the name of the inventory item @param aCount the number of items in stock */ public Pair(String aName, int aCount) { name = aName; count = aCount; } @@@@@@@@@@@@@ This constructor should be called InventoryItem @@@@@@@@@@@@ /** Gets the number of items in stock @return the count of inventory items */ public int getCount() { return count; } /** Gets the name of the item @return the name of the item */ public String getItemName() { return name; } /** Computes the new inventory amount in stock after added quantity @param numberToAdd the amount to increase the inventory quantity */ public void addToInventory( int numberToAdd) { count = count + numberToAdd; } /** Computes the new inventory amount in stock after subtracted quantity @param numberToRemove the amount to decrease the inventory quantity */ public void removeFromInventory( int numberToRemove) { count = count - numberToRemove; } private String name; private int count; } //end class InventoryItem --------- 12. /** This class takes input for an integer and then computes the sum of its digits @author Janine Bouyssounouse */ public class DigitalSum { /** Constructs a default DigitalSum */ public DigitalSum() { number = 0; hundreds = 0; tens = 0; ones = 0; sum = 0; } /** Constructs an InventoryItem @param aName the name of the inventory item @param aCount the number of items in stock */ public DigitalSum(int aNumber) { number = aNumber; hundreds = 0; tens = 0; ones = 0; sum = 0; } /** Breaks the number down into the hundreds digit, the tens digit, and the ones digit and then adds those digits together to find the sum of them @return the sum of the digits */ public int getSum() { hundreds = number / 100; tens = (number - (hundreds * 100)) / 10; ones = (number - (hundreds * 100)) - (tens * 10); return hundreds + tens + ones; } private int number; private int hundreds; private int tens; private int ones; private int sum; } //end DigitalSum ------------------------ import java.io.*; /** This is a class that uses the DigitalSum class to find the sum of the digits in a number between 0 and 1000. @author Janine Bouyssounouse */ public class DigitalSumTest //class definition { /** Uses the methods of the DigitalSum class. @param args not used */ public static void main(String[] args) throws IOException { InputStreamReader keyIn = new InputStreamReader(System.in); BufferedReader reader = new BufferedReader(keyIn); String input = ""; int number = 0; boolean done = false; //requires input until response is > 0 and less than 1000 while (!done) { System.out.print("Enter an integer between 0 and 1000: "); input = reader.readLine(); number = Integer.parseInt(input); @@@@@@@@@@@@@@ indent the statements in the while loop You should indent every time you use a left brace { @@@@@@@@@@@@ if(number > 0 && number < 1000) done = true; } @@@@@@@@@@@@@@ this is a good way to do the loop - @@@@@@@@@@@@@ //constructs a Pair object DigitalSum dSum = new DigitalSum(number); //gets the sum of the integers and prints it System.out.print("The sum of the digits of " + number); System.out.println(" is " + dSum.getSum()); } //end main method } //end class DigitalSumTest --------- ---------------- The correct answers: --------- 1. c --------- 2. b --------- 3. c --------- 4. d --------- 5. b --------- 6. b --------- 7. c --------- 8. a --------- 9. d --------- 10. b --------- 11. --------- 12. --------- ---------------- Comments on Bouyssounouse_Janine's test: 1. CORRECT. 2. CORRECT. 3. CORRECT. 4. CORRECT. 5. CORRECT. 6. CORRECT. 7. CORRECT. 8. CORRECT. 9. CORRECT. 10. (-5) b should be checked. (-5) d shouldn't be checked. [Total points charged for this problem: (-2)] 11.Possible -> 100, Actual *--> 95 12.Possible -> 80, Actual *--> 80 Total non-essay possible: 20 Calculated non-essay points for Bouyssounouse_Janine -->> 18 Total outstanding essay problem points: 180 Total points awarded for word problems *---> 175 Quiz #5 Student ID: bouyssounouse6788 (Bouyssounouse_Janine) Time Stamp: Date: 7/30/2004, Time: 8:13 PM ---------------- Elapsed Time: 14 minutes Answers submitted by Bouyssounouse_Janine: 1. java.lang ----------------- 2. Comparable, Serializable ----------------- 3. No, because it is final. ----------------- 4. java.lang.Object ----------------- 5. Yes, String(char[] value) ----------------- 6. Yes, String(byte[] bytes) ----------------- 7. trim() ----------------- 8. int ----------------- 9. String number = valueOf(342.75); ----------------- 10. Returns a new string resulting from replacing all occurrences of oldChar in this string with newChar. -----------------  The correct answers: 1. java.lang ----------------- 2. Comparable, Serializable ----------------- 3. No. It is a final class and can not have any subclasses. ----------------- 4. Object ----------------- 5. Yes String(char[] value) Allocates a new String so that it represents the sequence of characters currently contained in the character array argument. ----------------- 6. No. ----------------- 7. trim() ----------------- 8. int ----------------- 9. String.valueOf(342.75); ----------------- 10. Ir returns a new string resulting from replacing all occurrences of oldChar in this string with newChar. -----------------  Comments on Bouyssounouse_Janine's test: 1.(This is a word problem and will not be evaluated immediately.) 2.(This is a word problem and will not be evaluated immediately.) 3.(This is a word problem and will not be evaluated immediately.) 4.(This is a word problem and will not be evaluated immediately.) 5.(This is a word problem and will not be evaluated immediately.) 6.(This is a word problem and will not be evaluated immediately.) 7.(This is a word problem and will not be evaluated immediately.) 8.(This is a word problem and will not be evaluated immediately.) 9.(This is a word problem and will not be evaluated immediately.) 10.(This is a word problem and will not be evaluated immediately.) ---------------- Total non-essay possible: 0 Your score: 0 There are still essay problems worth a total of 10 additional points that will be evaluated by your instructor. Your submission has been received. ***************************************** Final Exam ***************************************** Student ID: bouyssounouse6788 (Bouyssounouse_Janine) Time Stamp: Date: 7/30/2004, Time: 11:50 PM ---------------- Elapsed Time: 8 minutes Answers submitted by Bouyssounouse_Janine: 1. /** This class describes a product with a string name and a double price. @author Janine Bouyssounouse */ public class Product { /** Constructs a default Product */ public Product() { name = "no name"; price = 0; } /** Constructs a Product @param aName the name of the product @param aPrice the price of the product */ public Product(String aName, double aPrice) { name = aName; price = aPrice; } /** Gets the price of a product @return the price of the product */ public double getPrice() { return price; } /** Gets the name of the product @return the name of the product */ public String getProductName() { return name; } /** Allows the user to change the name of a product @param newName the new name for the product */ public void changeName(String newName) { name = newName; } /** Allows the user to change the price of a product @param newPrice the new price of the product */ public void changePrice(double newPrice) { price = newPrice; } private String name; private double price; } // end class Product ----------------- 2. /** This converts the object to a string @return objectString the object as a string */ public String objectString() { return toString(); } ----------------- 3. /** This compares the object to parameters passed @return match the true or false of the compare @param aName the product name to be compared @param aPrice the product price to be compared */ public boolean equals(String aName, double aPrice) { boolean match = false; if(name.equalsIgnoreCase(aName) && price == aPrice) { match = true; } else { match = false; } return match; } ----------------- 4. /** This declares and instantiates an array of products with names and prices */ public void productArray() { final int NUM_PRODUCTS = 100; final int NUM_COLUMNS = 2; String[][] productListing = new String[NUM_PRODUCTS][NUM_COLUMNS]; } ----------------- 5. productListing[0][0] = "widget"; productListing[0][1] = "5429.99"; ----------------- 6. /** This determines the size of an array of products and prices called catalog as well as computing the total of all of the prices of the items in the catalog @return totalPrice the sum of all of the prices in the catalog */ public void totalCatalog() { int numItems = catalog.length; double sum = 0; for (int i = 0; i < numItems; i++) { sum = sum + Double.parseDouble(catalog[i][1]); } System.out.println("The number of items in the catalog is " + numItems); System.out.println("The total of all of the prices in the catalog is " + sum); } ----------------- 7. boolean match = catalog.equals("clock207", 10.50); ----------------- 8. -9 is even ----------------- 9. String name = "Foothill"; System.out.println("This prints out hill. " + name.substring(4, 8)); System.out.println("The length of the string is " + name.length()); ----------------- 10. public static void square(int aNumber) { return aNumber * aNumber; } ----------- public static void square(double aNumber) { return aNumber * aNumber; } Yes, It can. Because you are allowed to overload – using the same name for different methods with different parameters. --------------- public class PowerTest { public static void main(String[] args) { System.out.println(Power.square(75)); } } -----------------  The correct answers: 1. ----------------- 2. ----------------- 3. ----------------- 4. ----------------- 5. ----------------- 6. ----------------- 7. ----------------- 8. ----------------- 9. ----------------- 10. -----------------  Comments on Bouyssounouse_Janine's test: 1.(This is a word problem and will not be evaluated immediately.) 2.(This is a word problem and will not be evaluated immediately.) 3.(This is a word problem and will not be evaluated immediately.) 4.(This is a word problem and will not be evaluated immediately.) 5.(This is a word problem and will not be evaluated immediately.) 6.(This is a word problem and will not be evaluated immediately.) 7.(This is a word problem and will not be evaluated immediately.) 8.(This is a word problem and will not be evaluated immediately.) 9.(This is a word problem and will not be evaluated immediately.) 10.(This is a word problem and will not be evaluated immediately.) ---------------- Total non-essay possible: 0 Your score: 0 There are still essay problems worth a total of 200 additional points that will be evaluated by your instructor. Your submission has been received. ***************************************** website created by Janine Bouyssounouse. Last updated 02/05/07