Write the code to define an array of double values, named prices and of length 3
ID: 3589854 • Letter: W
Question
Write the code to define an array of double values, named prices and of length 3. Assign values of your choice to the positions in the array. TRACE YOUR CODE 3. Based on the videos, which of the following common "bugs" did Dr. Novick NOT create? Circle your answer. 4. Entered an input value which resulted in integer division by zero, causing an ArithmeticException to a. be generated. b. Spelled the name of his Scanner variable differently in a statement than he did when he declared it. c. Caused an incorrect computation order for converting temperatures due to lack of parentheses. d. Caused an Input MíismatchException to be created by entering a floating point value as input data when nextlnt0 was used to read it. e. Neglected to prompt the user that input data should use the metric system 5. Dr. Novick identified six phases for a thorough debugging process: Issue recognition, identifying exactly what it is about the program's behavior that seems incorrect. Intelligence gathering, examining the program to understand the way that it works and the way the error is being produced. Diagnosis, identifying the specific cause of the symptom, the bug itself. . . . Prescription, planning how to fix the bug. Response, following the plan to fix the bug Verification, checking that the bug is now fixed-and that the fix has not created other bugs!Explanation / Answer
Java Code For Defining Array of double and assigning values.
public class DoubleArray {
public static void main(String args[]) {
//initializing array to store 3 values
double[] prices = new double[3];
//Assigning some values to the positions in prices
prices[0] = 12.3456; //first element starts with 0 index
prices[1] = 45.83;
prices[2] = 2.984;
//print values
for(double val:prices){
System.out.println(val);
}
}
}
Tracing Code:
We can trace code using breakpoints in any IDE.
In Eclipse
1. Right click on line number on left side where you want to put breakpoint and click Toggle Breakpoint option. OR double click on line number.
2. Now execute program.
3. To continue use F8.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.