1/14
Flashcards covering review questions for ITEC-2140 Programming Fundamentals, including class design, array methods, loops, sentinel-controlled loops, conditional logic, and Scanner input handling.
Where must students submit their completed code for the ITEC-2140 Final Review assignments?
To GradeScope (they should not be submitted in D2L).
What attributes, constructor, and methods are required to be defined for the Pr1Purchase class?
Three attributes (location, description, and amount), a constructor with three parameters, setters and getters for each attribute, and a toString method.
How do Pr1PurchaseAppV1 and Pr1PurchaseAppV2 differ in how they create Pr1Purchase objects?
Pr1PurchaseAppV1 creates three Pr1Purchase objects directly in the main method with hardcoded data, whereas Pr1PurchaseAppV2 prompts the user for inputs to create the three objects.
What is the specified behavior of the search method in Pr2ArraySearch when searching for a key?
It searches the array for a given key and returns the index of the first occurrence of the key in the array (or −1 if the key is not found).
What statistics does the Pr3ArrayMethods program calculate and display after reading the array values?
It calculates and displays the total, average, maximum (max), and minimum (min) of the array elements.
In Question 4 (ScoreStatistics.java), what sentinel value terminates score input, and how is it handled during calculations?
The input sequence terminates with −1, and the sentinel value −1 must not be counted in the calculation of the average, maximum, or minimum scores.
What two methods must be implemented in Question 5 to compute the sequence 2,4,6,8,…,n?
sumToN(int n) and productToN(int n).
In Question 5, what are the resulting sum and product when the user enters the even integer n=16?
The sum is 72 (2+4+⋯+16=72) and the product is 10321920 (2×4×⋯×16=10321920).
What two methods must be implemented in Question 6 to calculate repeated operations of v over n times?
sumOfValues(int n, double v) and productOfValues(int n, double v).
In Question 7 (BMI and HBA1C), under what specific condition should the program print "You are overweight or obese."?
When the BMI is greater than or equal to 25.0 (BMI≥25.0).
In Question 7 (BMI and HBA1C), under what specific condition should the program print "You may have diabetes."?
When the HBA1C level is over 5.7% (HBA1C>5.7%).
According to the weight category table in Question 8, what are the BMI ranges for "Underweight" and "Normal"?
"Underweight" is BMI<18.5, and "Normal" is 18.5≤BMI<25.0.
According to the weight category table in Question 8, what are the BMI ranges for "Overweight" and "Obese"?
"Overweight" is 25.0≤BMI<30.0, and "Obese" is 30.0≤BMI.
In Question 9 (Overtime Or Not), what are the conditions under which an employee is considered to have worked overtime?
If it is the weekend, any hours worked greater than 0 (hours>0) is overtime. If it is not the weekend, it is overtime only if the hours worked is over 40 hours (hours>40).
In Question 10, why must Scanner's nextLine() method be used instead of next() when prompting for names?
next() only reads a single word, whereas nextLine() reads an entire line, allowing user inputs that contain multiple words separated by spaces.