Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Java Outline (Upto Exam 1) Sections to do on Website: http://chortle.ccsu.edu/java5/index.html#03 Part 2 Running Java Programs Chapter 5 Hand in Program Assignment (5 marks): Create a program called “FirstProg” that will do the following: 1. Print the message “My name is _____.” 2. Print the message “This is my first assignment in Java.” 3. Print the message “Mr. Kerbrat is the nicest teacher.” (or something similar!!) You must print off the source code. Marks 1. /2 for proper comments (header) 2. /3 for proper code Notes Assignment Chapter 5 (5 marks) Briefly define the following terms in your own words (do not copy/paste from the website): 1. source program 2. bytecode 3. Java Virtual Machine 4. portable 5. applet Important: • Your notes must be typed. • Include your name and the heading at the top of the notes (Ex John Doe: Notes for Chapter 5) For an exam, know how to: • use JCreator to make the source program (textfile called ___.java) • compile the program into a ____.class file. • run the program to see what it does and if it works Chapter 6 For an exam, know how to: • create a simple program (including all the brackets needed) • output info to the screen => System.out.println(“ ”); • properly indent your source code Notes Assignment Chapter 6 (3 marks) Briefly define the following terms in your own words (do not copy/paste from the website): 1. main method 2. syntax error 3. comment Part 3 Data Chapter 8 (Primitive Data) Notes Assignment Chapter 8 (9 marks) Answer the following questions in your own words (do not copy/paste from the website): 1. What is a data type? (/1) 2. List 8 primitive data types and briefly tell what each is. (8 marks) Be sure to state which are for integers and which are for decimals! Chapter 9A (Variables and the Assignment Statement) Hand in Program Assignment (14 marks): Create a program called “Convert” that will do the following: 1. Convert an integer type number from yards to feet. Note: 1 yard = 3 feet (Ex. The output for this part could be: 6 yards = 18 feet) 2. Convert a decimal number from Celsius to Fahrenheit. Note: F = 1.8C + 32 (Ex. The output for this part could be: 5.5 C = 41.9 F) 5 3. Convert a decimal number from Fahrenheit to Celsius. Note: C = (F – 32) 9 4. Convert a double type number to its square. (Ex. The output for this part could be: The square of 20 is 400) 5. Convert a double type number to its square root. (Ex. The output for this part could be: The square root of 144 is 12) You must print off the source code. Marks Suggestion: 1. /2 for proper comments (header) Test each section one part at a 2. /2 for conversion code (yards to feet) time rather than trying to write 3. /2 for conversion code (Celsius to Fahrenheit) the entire program and then test 4. /2 for conversion code (Fahrenheit to Celsius) the entire program. 5. /2 for conversion code (number to number2) 6. /2 for conversion code (number to its square root) 7. /2 for using the proper primitive data types Notes Assignment Chapter 9A (7 marks) Briefly define the following terms in your own words (do not copy/paste from the website): 1. variable 2. identifier 3. reserved word 4. assignment statement 5. expressions 6. arithmetic operators 7. precedence (order of operations) For an exam, know how to: • declare variables (See Question 6 in Chapter 9A) • choose which variable types you use for numbers with decimal places • use assignment statements • know basic arithmetic operators and order of operations • Use of the + operator in System.out.println statements to combine text and variables Chapter 9C (Object Data) Hand in Program Assignment (8 marks): Create a program called “Chp9CStrings” that will do the following: 1. Create a string object and assign a phrase (at least 3 words) to the new string variable 2. Print out the last 3 letters of the phrase followed by the message “is the last 3 letters” 3. Print out the first word of the phrase followed by the message “is the first word” 4. Print out the phrase with no spaces in between the words 5. Print out the phrase in all capital letters 6. Print out the phrase followed by a message “has ?? characters in it” Marks 1. /1 for proper comments (header) 2. /2 for string declaration 3. /5 for the 5 print outs Notes Assignment Chapter 9C (6 marks) Briefly define the following terms in your own words (do not copy/paste from the website): 1. What is an object? (See page on website titled “Picture of an object”) 2. What is a class? (See page on website titled “Picture of an object”) 3. String object 4. constructor (may be difficult to find on website) 5. object reference 6. package (know this in general…for ex. java.util package) For an exam, know how to: • create a String object (using new String …) • use methods for Strings with dot notation (Ex. substring(), len(), trim(), toUpperCase() ) Chapter 10 (Input and Output) Hand in Program Assignment (20 marks): Create a program called “Input” that will do the following: 1. Ask user for their name. Print a message that says “Hello theirname” 2. Ask user for a number from 1 to 100. Print a message that doubles their number. (Ex. The double of 22 is 44) 3. Ask user for a decimal number between 1 and 10. Ask user for a second number between 1 and 10. Print a message that divides the 2 numbers. (Ex. 4.6 divided by 2.7 is 1.703703704 ) 4. Ask user for a degree in Celsius. Print the amount in Fahrenheit. (Ex. 12.5 Celsius is 54.5 Fahrenheit) 5. Ask user for a degree in Fahrenheit. Print the amount in Celsius. 6. Ask user for number of cents. Print the amount of dollars and cents. (Ex. 345 cents is 3 dollars and 45 cents ) Hint: Review the integer remainder operator %. See Chp10 Integer Division Tester program which is the 2nd last page of Chp10 on the Website for Java. 7. Ask user for radius of a circle. Print the area of the circle. Use 3.14 for Pi or use Math.PI for a more accurate amount. (Ex. Circle with a radius of 4 units has an area of 50.24 square units) Below are is the Math class and some methods you may want to use in your assignment. You are expected to use at least 4 of these methods in this assignment: Math. PI (the constant PI, 3.14159….) Math.round(num) (rounds num to nearest integer, no decimals) Math.floor(num) (cuts off the decimals) Math.round(num*100.0) / 100.0 (rounds num to nearest 2 decimal places, must use 100.0) Marks 1. 2. 3. 4. 5. 6. 7. 8. /2 for proper comments (header + other meaningful comments) /2 for name section of code /2 for doubling section of code /3 for dividing 2 numbers section of code /2 for Cel to Fah code Note: See Chp9A “convert” program for help with this /2 for Fah to Cel code /3 for dollars,cents code /4 for Math class Notes Assignment Chapter 10 (3 marks) Briefly define the following terms in your own words (do not copy/paste from the website): 1. I/O 2. Input vs Output 3. Scanner Object For an exam, know how to: • use System.in and Scanner Object to input data • use System.out to output data • use nextLine() , nextInt() , nextDouble() methods with Scanner Object Chapter 11 (Floating Point) For an exam, know how to: 1. use nextDouble() method with Scanner Object 2. use the class Math with square roots, PI There is no assignment for this Chapter. Read over for your own knowledge. EXAM #1 You may not use notes or the computer for definitions on the exam. You will be able to use notes and the computer for all other sections of the exam.