Slide 1

Slide 1 text

CSE110 Principles of Programming with Java Lecture 18: Review for the Second Midterm Javier Gonzalez-Sanchez [email protected] javiergs.engineering.asu.edu | javiergs.com Office Hours: By appointment

Slide 2

Slide 2 text

Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 2 Midterm 1

Slide 3

Slide 3 text

Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 3 Midterm 2

Slide 4

Slide 4 text

Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 4 Disclaimer The following questions are just examples. They are NOT a comprehensive list of topics Review All the Slides for a full list of topics The exam is NOT limited to the topics covered in this review. Midterm Exams are comprehensive

Slide 5

Slide 5 text

Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 5 Day 10 switch statement 1. Ask the user for a number 1 to 3 2. If the number is not 1, 2, or 3 show an error message “invalid input” and ask again. 3. If number 1 print “stone” 4. If number 2 print “paper” 5. If number 2 print “scissor” Operator ? • Ask for two integer numbers (a and b) • Using operator ?, store the highest in a new variable.

Slide 6

Slide 6 text

Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 6 Day 11 while and do-while statements 1. Ask the user for a number (1 to 10) 2. If the numbers are not 1 to 10 show an error message “invalid input” and ask again. 3. Draw a square using the two numbers as length. For instance, if the user input 3 and 6, draw ****** ****** ******

Slide 7

Slide 7 text

Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 7 Day 12 for statements In mathematics, the Fibonacci numbers are the numbers in the following integer sequence, called the Fibonacci sequence, and characterized by the fact that every number after the first two is the sum of the two preceding ones 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144,…

Slide 8

Slide 8 text

Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 8 Day 13 Conditions and loops Draw this pattern in the screen. Example 6 x 20 0***|0***|0***|0**** *0**|*0**|*0**|*0*** **0*|**0*|**0*|**0** ***0|***0|***0|***0* ****0****0****0****0 ****|0***|0***|0****

Slide 9

Slide 9 text

Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 9 Day 15 Object-oriented programming 1. Create a class Box 2. Include a variables: length, width, and height 3. Create a method that return the volume of the box, called calculateVolume() 4. Create a class MyProgram that have a method main(). It creates two boxes, put values to their dimensions, and print their volumes calling calculateVolume()

Slide 10

Slide 10 text

Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 10 Day 16 Classes and Objects Create the classes needed to make this line work: public class Exam{ public static void main (String []a) { Doctor doc = new Doctor(); Doctor.color = "white”; doc.name = "Dr. Who”; doc.age = 90; doc.writePrescription(); // This is your prescription doc.hello(); //print name, age, and color. } }

Slide 11

Slide 11 text

Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 11 Day 17 Methods Create the classes needed to make this line work: public class Exam{ public static void main (String []a) { Genius g = new Genius(); double x = g.areaOfCirleWithRadius(10); double x = g.areaOfTriangle(10,20); g.printFirst5FibonacciNumbers(); g.printFirst9FibonacciNumbers(); } }

Slide 12

Slide 12 text

Javier Gonzalez-Sanchez | CSE110 | Summer 2020 | 12 Disclaimer The following questions are just examples. They are NOT a comprehensive list of topics Review All the Slides for a full list of topics The exam is NOT limited to the topics covered in this review. Midterm Exams are comprehensive

Slide 13

Slide 13 text

CSE110 - Principles of Programming Javier Gonzalez-Sanchez [email protected] Summer 2020 Disclaimer. These slides can only be used as study material for the class CSE110 at ASU. They cannot be distributed or used for another purpose.