
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
7th Edition
ISBN: 9780134802213
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 7, Problem 11PC
Array Operations
Write a
- getTotal. This method should accept a one-dimensional array as its argument and return the total of the values in the array.
- getAverage. This method should accept a one-dimensional array as its argument and return the average of the values in the array.
- getHighest. This method should accept a one-dimensional array as its argument and return the highest value in the array.
- getLowest. This method should accept a one-dimensional array as its argument and return the lowest value in the array.
Demonstrate each of the methods in the program.
Expert Solution & Answer

Want to see the full answer?
Check out a sample textbook solution
Students have asked these similar questions
Boolean Algebra HW #4
Show all intermediate steps (truth tables, algebraic steps, and justifications such as identities
or theorems) for full credit.
1. Evaluate the following expression when A = 1, B = O, C = 1, D = 0
F = AB + CD + (A+B)C
2. Find F, the complement of function F, Write your answer using overbars.
F(W,X,Y,Z) = WX+YZ+XZ
3. Determine the truth table for the function
F=XY+XZ
4. Show with a truth table that the following is true:
X(Y+Z) = XY+XZ
5. Simplify the following Boolean expression. Show each simplification step and identity used.
a) AB + AB + ABC
b) (M+N)(M + P) + MP
6. Find the dual of the Boolean expressions. (swap + with and O with 1; do not complement
variables).
a) ABC
b) (X + Y)(X + Z)
c) P+Q+ RS
7. Convert Standard POS form to Canonical POS form.
•
(A+B)(Ā + C) (B+C)
8. Given that F(a, b, c, d) = Em(1, 3, 4, 6, 8, 9, 12)
(i) Write the product of maxterms (canonical POS) for F.
(ii) Write the canonical SOP and canonical POS for F.
Consider the following statement, which is intended to assign the value of the expression,
the variable result Assume that the double variables. x-ya and b have been properly
declared and initialized.
(xy)
to
double result = missing code /:
17
Mark for Review
Which of the following can replace / missing code / so that the statement works as intended?
Math.sqrt((x + y)
2/ Math.abs(a, b))
Math.sqrt((x + y) 2/ Math.abs(a - b))
Math.sqrt(Math.pow(x + y, 2) / Math. abs(a, b))
Math.sqrt(Math.pow(x + y, 2) / Math.abs (a - b))
Consider the following code segment, which is intended to print the digits of the two-digit int number
num in reverse order. For example, if num has the value 75, the code segment should print 57.
Assume that num has been properly declared and initialized.
/missing code */
System.out.print (onesDigit);
System.out.print (tensDigit);
14
Mark for Review
Which of the following can be used to replace / missing code so that the code
segment works as intended?
int onesDigit num 10;
int tensDigit num / 10;
int onesDigit- num / 10;
int tensDigit num 10;
int onesDigit -10/num;
int tensDigit 10 num;
-Undo
int onesDigit
num
100;
Undo
int tensDigit-num / 100;
Chapter 7 Solutions
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Ch. 7.1 - Write statements that create the following arrays:...Ch. 7.1 - Whats wrong with the following array declarations?...Ch. 7.1 - Prob. 7.3CPCh. 7.1 - Prob. 7.4CPCh. 7.1 - Prob. 7.5CPCh. 7.1 - Prob. 7.6CPCh. 7.1 - Prob. 7.7CPCh. 7.1 - Prob. 7.8CPCh. 7.2 - Prob. 7.9CPCh. 7.2 - Prob. 7.10CP
Ch. 7.2 - A program has the following declaration: double[]...Ch. 7.2 - Look at the following statements: int[] a = { 1,...Ch. 7.3 - Prob. 7.13CPCh. 7.3 - Write a method named zero, which accepts an int...Ch. 7.6 - Prob. 7.15CPCh. 7.7 - Recall that we discussed a Rectangle class in...Ch. 7.10 - Prob. 7.17CPCh. 7.11 - What value in an array does the selection sort...Ch. 7.11 - How many times will the selection sort swap the...Ch. 7.11 - Prob. 7.20CPCh. 7.11 - Prob. 7.21CPCh. 7.11 - If a sequential search is performed on an array,...Ch. 7.13 - What import statement must you include in your...Ch. 7.13 - Write a statement that creates an ArrayList object...Ch. 7.13 - Write a statement that creates an ArrayList object...Ch. 7.13 - Prob. 7.26CPCh. 7.13 - Prob. 7.27CPCh. 7.13 - Prob. 7.28CPCh. 7.13 - Prob. 7.29CPCh. 7.13 - Prob. 7.30CPCh. 7.13 - Prob. 7.31CPCh. 7 - In an array declaration, this indicates the number...Ch. 7 - Each element of an array is accessed by a number...Ch. 7 - The first subscript in an array is always. a. 1 b....Ch. 7 - The last subscript in an array is always. a. 100...Ch. 7 - Array bounds checking happens. a. when the program...Ch. 7 - This array field holds the number of elements that...Ch. 7 - Prob. 7MCCh. 7 - This search algorithm repeatedly divides the...Ch. 7 - Prob. 9MCCh. 7 - When initializing a two-dimensional array, you...Ch. 7 - Prob. 11MCCh. 7 - To delete an item from an ArrayList object, you...Ch. 7 - To determine the number of items stored in an...Ch. 7 - True or False: java does not allow a statement to...Ch. 7 - True or False: An arrays sitze declarator can be a...Ch. 7 - Prob. 16TFCh. 7 - True or False: The subscript of the last element...Ch. 7 - Prob. 18TFCh. 7 - True or False: The Java compiler does not display...Ch. 7 - Prob. 20TFCh. 7 - True or False: The first size declarator in the...Ch. 7 - Prob. 22TFCh. 7 - Prob. 23TFCh. 7 - int[] collection = new int[-20];Ch. 7 - Prob. 2FTECh. 7 - Prob. 3FTECh. 7 - Prob. 4FTECh. 7 - Prob. 5FTECh. 7 - The variable names references an integer array...Ch. 7 - The variables numberArray1 and numberArray2...Ch. 7 - Prob. 3AWCh. 7 - In a program you need to store the populations of...Ch. 7 - In a program you need to store the identification...Ch. 7 - Prob. 6AWCh. 7 - Prob. 7AWCh. 7 - Prob. 8AWCh. 7 - Prob. 9AWCh. 7 - Prob. 10AWCh. 7 - Prob. 11AWCh. 7 - Prob. 1SACh. 7 - Prob. 2SACh. 7 - Prob. 3SACh. 7 - Prob. 4SACh. 7 - Prob. 5SACh. 7 - Prob. 6SACh. 7 - Prob. 7SACh. 7 - Prob. 8SACh. 7 - Prob. 9SACh. 7 - Rainfall Class Write a RainFall class that stores...Ch. 7 - Payroll Class Write a Payroll class that uses the...Ch. 7 - Charge Account Validation Create a class with a...Ch. 7 - Charge Account Modification Modify the charge...Ch. 7 - Prob. 5PCCh. 7 - Drivers License Exam The local Drivers License...Ch. 7 - Magic 8 Ball Write a program that simulates a...Ch. 7 - Grade Book A teacher has five students who have...Ch. 7 - Grade Book Modification Modify the grade book...Ch. 7 - Average Steps Taken A Personal Fitness Tracker is...Ch. 7 - Array Operations Write a program with an array...Ch. 7 - Prob. 12PCCh. 7 - Sorted List of 1994 Gas Prices Note: This...Ch. 7 - Name Search If you have downloaded this books...Ch. 7 - Population Data If you have downloaded this books...Ch. 7 - World Series Champions If you have downloaded this...Ch. 7 - 2D Array Operations Write a program that creates a...Ch. 7 - Prob. 18PCCh. 7 - Trivia Game In this programming challenge, you...Ch. 7 - Prob. 20PC
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
17–1C A high-speed aircraft is cruising in still air. How does the temperature of air at the nose of the aircra...
Thermodynamics: An Engineering Approach
Money Counting Game Create a change-counting game that gets the user to enter the number of coins required to m...
Starting Out with Python (4th Edition)
What is an object? What is a control?
Starting Out With Visual Basic (8th Edition)
Random Number Guessing Game Write a program that generates a random number and asks the user to guess what the ...
Starting Out with C++ from Control Structures to Objects (9th Edition)
Declare method sphereVolume to calculate and return the volume of the sphere. Use the following statement to ca...
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Write a program that determines the change to be dispensed from a vending machine. An item in the machine can c...
Java: An Introduction to Problem Solving and Programming (8th Edition)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- The following code segment is intended to round yal to the nearest integer and print the result double val--0.7 int roundedVal (int) (val +0.51 System.out.println(roundedValu 25 Mark for Review Which of the following best describes the behavior of the code segment? The code segment does not work as intended because the expression (val +0.5) should be cast to a double instead of an int The code segment does not work as intended because val should be cast to an int before 0.5 is added to it. Highlights & Notes Reference Undo Undo The code segment does not work as intended because the expression -Unda positive ר .arrow_forwardIn the following code segment, mon and tue are properly declared String variables. String strl-mon.substring(9. mon.indexOf(" "). String str2-tue.substring(tue.indexOf(" ") + 1). System.out.println(strl+and+str2): க 21 Mark for Review For which of the following values of mon and tue will the code segment print "cloudy and foggy"? mon tue "cloudy today" "foggy tomorrow" mon tue "cloudy today" "tomorrow foggy" mon tue "today cloudy" "foggy tomorrow" mon tue "today cloudy" "tomorrow foggy"arrow_forwardG Consider the following code segment, which is intended to assign to num a random integer value between min and max, inclusive, each with an equal chance of being assigned to num. Assume that min and max are integer variables and that the value of max is greater than the value of min. 24 Mark for Review Which of the following can replace /* missing code */ so that the code segment works as intended? double rn = Math.random();_ int num = /* missing code */ ;_ D (int) (rn * max) + min ABC (A) (int) (rn * (max- min)) + min (B (int) (rn * (max min)) + 1 (int) (rn * (max min + 1)) + minarrow_forward
- Write the truth table for each of the following logic functions: (a) FX Y+X'. Y'. Z (b) FW' X + Y' · Z' + X' · Z (c) F=W+X' · (Y' + Z) . . (d) F A B+ B' C+C' D + D' A .arrow_forwardUse the theorems of switching algebra to simplify each of the following logic functions: (a) F W X Y Z (W X Y . Z'+W X Y Z (b) FA B+ A . B C D+A B.D. E' + A B C W X Y Z+W X Y' - Z) E + C D E .arrow_forwardWrite the canonical sum and product for each of the following logic functions: (a) F = Σx,y(1,2) (c) F=ΣA,B,C(2,4,6,7) = (b) FПAB(0,1,2) (d) F=Пw.x,y(0,1,3,4,5)arrow_forward
- For the following truth table: a) Write the canonical SOP. Row × Y Z F 0 0 0 0 0 b) Write the canonical POS. | 0 0 1 2 0 1 0 1 3 0 1 1 0 4 1 0 0 0 5 1 0 1 1 6 1 1 0 0 7 1 1 1 1arrow_forward(团) (四) The Dog class has a constructor that takes two parameters. The first parameter is a String representing a dog's name and the second parameter is an int representing the dog's age, in months. 9 Mark for Review ARC The following code segment appears in a class other than Dog. Which of the following best describes the contents of dog1 and dog2 as a result of executing this code segment? Dog dogl new Dog ("Rex", 4); Dog dog2 dogl dog1; new Dog("Fido", 60); dog1 and dog2 are Dog variables that each contain the same Dog object, which represents a dog named "Fido' that is 60 months old. dogl is a Dog variable that contains a Dog object representing a dog named "Fido" that is 60 months old, and dog2 is a Dog variable that contains a Dog object representing a dog named "Rex" that is 4 months old. dogl and dog2 are Dog reference variables that each contain a reference to the same memory address that contains the Dog object representing a dog named "Fido' that is 60 months old. dogl is a…arrow_forwardThe following code segment is intended to assign to newword the result created by removing the first occurrence of "a" from word. Assume that the String variable word has been properly declared and initialized. This code segment works for some, but not all, values of word. int aLoc word.indexOf("a"); String newword word.substring(0, aLoc) + word.substring(aLoc + 1); 18 Mark for Review Which of the following conditions best describes the condition in which this code segment will not work a intended and will result in a runtime error? is the first character in word. is the last character in word. word does not contain the character "a". word contains only a sequence of multiple "a" characters.arrow_forward
- Consider the following code segment, which is intended to create a String that consists of the last character in word and assign it to the variable lastChar String word / initialization not shown */; // line 1 int len word.length(); // line 2 String lastChar word.substring(len); // line 3 17 Mark for Review Which of the following best describes why this code segment will not work as intended? substring needs to be called with two parameters, so the method call in line 3 should be changed to word.substring(len, len + 1). len is not the correct index of the last character in word, so the method call in line 3 should be changed to word.substring(len - 1). len is not the correct index of the last character in word, so the method call in line 3 should be changed to word.substring(len + 1). substring cannot be called with a variable as the parameter, so the method call in line 3 should be changed to word.substring (word.length()). ABCarrow_forwardConsider the following code segment. String one String two "computer"; "science"; String concat / missing code */; System.out.println(concat); 2 16 Mark for Review ARC Which of the following expressions can be used to replace/missing code / so that the code segment prints the string "pun"? one.substring(3, 4) + two.substring(4, 4) one.substring(3, 5) + two.substring(4, 5) one.substring(4, 5) + two.substring(5, 5) one.substring(4, 6) + two.substring(5, 6)arrow_forwardPlease R show code and output for the following questions.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
- Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,

EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage

C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning

Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning

C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr

Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Program to find HCF & LCM of two numbers in C | #6 Coding Bytes; Author: FACE Prep;https://www.youtube.com/watch?v=mZA3cdalYN4;License: Standard YouTube License, CC-BY