Seating chart 5 rows 2 rows 5 rows

  • Slides: 16
Download presentation
Seating “chart” 5 rows 2 rows 5 rows Front 4 rows Back 5 rows

Seating “chart” 5 rows 2 rows 5 rows Front 4 rows Back 5 rows 2 rows 5 rows

Quiz YOU WILL WORK WITH YOUR PARTNER (LAB PARTNER NOT FULL TEAM). YOU WILL

Quiz YOU WILL WORK WITH YOUR PARTNER (LAB PARTNER NOT FULL TEAM). YOU WILL HAVE 20 MINUTES.

Quiz Grading Pass your quiz to another team in a different section than you.

Quiz Grading Pass your quiz to another team in a different section than you. As we go over each question, grade it based on the points and result.

Question 1 Which of the following is not a valid assignment statement, assuming all

Question 1 Which of the following is not a valid assignment statement, assuming all variables have been declared and initialized with an appropriate data type? ◦ total = sum + next; ◦ keyboard. next. Int() = value; ◦ count = count + flag; ◦ rate = 10. 2;

Question 2 Which. Car. java: 44: possible loss of precision found : double required:

Question 2 Which. Car. java: 44: possible loss of precision found : double required: int cost = total. Cost; What is the possible cause of this error? a. cost has not been declared b. cost has not been initialized c. total. Cost has not been initialized d. cost is an int and total. Cost is a double

Question 3 Which. Car. java: 44: possible loss of precision found : double required:

Question 3 Which. Car. java: 44: possible loss of precision found : double required: int cost = total. Cost; On what line number in the source file does this error occur? ◦ Line 0 ◦ Line 15 ◦ Line 44 ◦ It is impossible to tell from the error message provided

Question 4

Question 4

Question 5 Declare a String variable named state. Then initialize the variable so it

Question 5 Declare a String variable named state. Then initialize the variable so it references an object with the string “Virginia”. String state; state = “Virginia”; ◦ OR state = new String (“Virginia”);

Question 6 Does the following statement compute the average of double variables a, b,

Question 6 Does the following statement compute the average of double variables a, b, and c? Why or why not? Explain double average = a + b + c / 3. 0; 1 pt – NO 1 pt – The c will be divided by 3 first and then that result will be added to a + b.

Question 7 Which of the following assignments are valid, given that the following variables

Question 7 Which of the following assignments are valid, given that the following variables are declared: int cost, double tax. Rate, float interest. Rate, long count a. interest. Rate = tax. Rate; b. cost = tax. Rate; c. count = cost; d. cost = count;

Question 8 Enclosing a group of statements inside a set of braces creates a

Question 8 Enclosing a group of statements inside a set of braces creates a a. block of statements b. boolean expression c. loop d. Nothing, it is just for readability

Practice - Solve a problem in pieces. In your teams, work on the following

Practice - Solve a problem in pieces. In your teams, work on the following problem: The distance between any two points, (x 1 y 1 and x 2 y 2) can be computed by the formula: Write a program to read in from the user the point values and then compute and print the distance in the form of: The distance between (x 1 y 1) and (x 2 y 2) is XXXX.

Think about this problem as a problem in 3 parts. Part 1 – Reading

Think about this problem as a problem in 3 parts. Part 1 – Reading in the input. 1. Think about the variables you will need. (At least one variable for each individual component of the points and a Scanner) and declare them. 2. Think about how you will prompt the user. 3. Perform the read operations to load the variables. Note: if you are writing the program, you could stop here and test by “echoing” the input via a temporary println to show that the variables hold the correct values.

Part 2 Calculating the result 1. Think about any additional variables you will need

Part 2 Calculating the result 1. Think about any additional variables you will need and declare them up top. 2. Create the calculation. Note that while this is a single formula, you might do better by breaking it down. Two Math class methods that might be useful are Math. pow() and Math. sqrt. 3. At this point you can test to see that the calculation is working correctly. If you are using sub calculations, you can also test them by putting in additional print statements.

Part 3 – Making the format pretty Now that you have the program producing

Part 3 – Making the format pretty Now that you have the program producing the correct result, add in print statements to display the result. Use the Decimal. Format class (another variable) if you wish or printf. If this is working correctly, you can then remove all of the unnecessary print statements that you used for testing.

Homework Finish up the work on this algorithm. You will be writing this program

Homework Finish up the work on this algorithm. You will be writing this program as one part of the work of Tuesday’s lab. There will be a weekly quiz and the focus will be on arithmetic operations.