Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
3rd Edition
ISBN: 9780134038179
Author: Tony Gaddis, Godfrey Muganda
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 9, Problem 9PC
Program Plan Intro
Word Counter
Program Plan:
The detail of “SumOfDigits” class is shown below:
- In the “main()” method,
- Declare and initialize the required variables.
- Create an object for Scanner class.
- Read the string of digits from user.
- Convert the string into a character array.
- The for loop executes until the array length. If yes,
- Convert an element into a String and then assign it.
- Convert the string into numeric value.
- Calculate the sum.
- Check whether “i” is equal to “0”. If yes, determine the highest and lowest.
- Otherwise, check whether “num” is greater than “highest”. If yes, assign the “num” as highest number.
- Check whether “num” is greater than “lowest”. If yes, assign the “num” as lowest number.
- Display the result of sum, highest, and lowest number.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Question
Write a statement
that declares a string
arrays initialized with
the following strings:
Write a loop that
display the content
of each element in
the array declared
in question 1
"Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday" and
"Sunday"
Any loop statement can be used to traverse an array.
True or False
C# In your main method use the method in question 1 to display the letters array, then use the Array.Reverse() method to reverse the letters array and then again call the appropriate method to print it
Chapter 9 Solutions
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
Ch. 9.2 - Prob. 9.1CPCh. 9.2 - Write an if statement that displays the word digit...Ch. 9.2 - Prob. 9.3CPCh. 9.2 - Write a loop that asks the user, Do you want to...Ch. 9.2 - Prob. 9.5CPCh. 9.2 - Write a loop that counts the number of uppercase...Ch. 9.3 - Prob. 9.7CPCh. 9.3 - Modify the method you wrote for Checkpoint 9.7 so...Ch. 9.3 - Look at the following declaration: String cafeName...Ch. 9.3 - Prob. 9.10CP
Ch. 9.3 - Prob. 9.11CPCh. 9.3 - Prob. 9.12CPCh. 9.3 - Prob. 9.13CPCh. 9.3 - Look at the following code: String str1 = To be,...Ch. 9.3 - Prob. 9.15CPCh. 9.3 - Assume that a program has the following...Ch. 9.4 - Prob. 9.17CPCh. 9.4 - Prob. 9.18CPCh. 9.4 - Prob. 9.19CPCh. 9.4 - Prob. 9.20CPCh. 9.4 - Prob. 9.21CPCh. 9.4 - Prob. 9.22CPCh. 9.4 - Prob. 9.23CPCh. 9.4 - Prob. 9.24CPCh. 9.5 - Prob. 9.25CPCh. 9.5 - Prob. 9.26CPCh. 9.5 - Look at the following string:...Ch. 9.5 - Prob. 9.28CPCh. 9.6 - Write a statement that converts the following...Ch. 9.6 - Prob. 9.30CPCh. 9.6 - Prob. 9.31CPCh. 9 - The isDigit, isLetter, and isLetterOrDigit methods...Ch. 9 - Prob. 2MCCh. 9 - The startsWith, endsWith, and regionMatches...Ch. 9 - The indexOf and lastIndexOf methods are members of...Ch. 9 - Prob. 5MCCh. 9 - Prob. 6MCCh. 9 - Prob. 7MCCh. 9 - Prob. 8MCCh. 9 - Prob. 9MCCh. 9 - Prob. 10MCCh. 9 - To delete a specific character in a StringBuilder...Ch. 9 - Prob. 12MCCh. 9 - Prob. 13MCCh. 9 - These static final variables are members of the...Ch. 9 - Prob. 15TFCh. 9 - Prob. 16TFCh. 9 - True or False: If toLowerCase methods argument is...Ch. 9 - True or False: The startsWith and endsWith methods...Ch. 9 - True or False: There are two versions of the...Ch. 9 - Prob. 20TFCh. 9 - Prob. 21TFCh. 9 - Prob. 22TFCh. 9 - Prob. 23TFCh. 9 - int number = 99; String str; // Convert number to...Ch. 9 - Prob. 2FTECh. 9 - Prob. 3FTECh. 9 - Prob. 4FTECh. 9 - The following if statement determines whether...Ch. 9 - Write a loop that counts the number of space...Ch. 9 - Prob. 3AWCh. 9 - Prob. 4AWCh. 9 - Prob. 5AWCh. 9 - Modify the method you wrote for Algorithm...Ch. 9 - Prob. 7AWCh. 9 - Look at the following string:...Ch. 9 - Assume that d is a double variable. Write an if...Ch. 9 - Write code that displays the contents of the int...Ch. 9 - Prob. 1SACh. 9 - Prob. 2SACh. 9 - Prob. 3SACh. 9 - How can you determine the minimum and maximum...Ch. 9 - Prob. 1PCCh. 9 - Prob. 2PCCh. 9 - Prob. 3PCCh. 9 - Prob. 4PCCh. 9 - Prob. 5PCCh. 9 - Prob. 6PCCh. 9 - Check Writer Write a program that displays a...Ch. 9 - Prob. 8PCCh. 9 - Prob. 9PCCh. 9 - Word Counter Write a program that asks the user...Ch. 9 - Sales Analysis The file SalesData.txt, in this...Ch. 9 - Prob. 12PCCh. 9 - Alphabetic Telephone Number Translator Many...Ch. 9 - Word Separator Write a program that accepts as...Ch. 9 - Pig Latin Write a program that reads a sentence as...Ch. 9 - Prob. 16PCCh. 9 - Lottery Statistics To play the PowerBall lottery,...Ch. 9 - Gas Prices In the student sample program files for...
Knowledge Booster
Similar questions
- //write code that loops through the two variables returns an array ['2 is zwei', '3 is drei', '4 is vier', '5 is fünf', '6 is sechs']// example:// return: ['2 is zwei', '3 is drei', '4 is vier', '5 is fünf', '6 is sechs']// hint: use Array.forEach, Array.map or a for loopfunction germanNumbers(){ const cardinalNumbers = [2,3,4,5,6]; const germanNumbers = ['zwei', 'drei', 'vier', 'fünf', 'sechs']; } // write code that returns an array of ONLY prime numbers that are in the array numbers// example: // return [2, 3, 5, 7, 11, 13]// hint use: Array.filterfunction returnPrimeNumbers(){ const numbers = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]; }arrow_forwardNote: Please use WHILE LOOP and print all the contents of the array. Use java language. Days of the Week. Create an array of Strings which are initialized to the 7 daysof the week. Use while-loop and print all the contents of the array.arrow_forwardA single statement that declares a variable and specifies array values as its content is called an array Select one: a.literal b.constructor C.element d.indexarrow_forward
- LAB The program enters the scores of an test for 10 students and saves them as an array. Then the program finds the minimum note, the maximum note, and the average. See below run of the program. If the input is 10 95 85 65 88 79 85 90 99 91 The output is Student Note 1 10 2 95 3 85 4 65 5 88 6 79 7 85 8 90 9 99 10 91 The minimum note is: 10 The maximum note is: 99 The average note is: 78.7arrow_forwardProgramming language is C#arrow_forwardTrue or FalseWhen you call a string object’s Split method, the method divides the string into two substrings and returns them as an array of strings.arrow_forward
- Weight Statistics Write a program that monitors monthly weight loss each of 12 months into an array of doubles. The program should calculate and display the total weight loss for the year, the average monthly weight loss, and the months with the highest and lowest amounts. Input Validation: Do not accept negative numbers for monthly weight loss.arrow_forward20- $footboll=array(); is an example of: a. boolean b. None c. function d. empty arrayarrow_forwardThis program calculates the average of 3 test scores and the grade is assigned according to the table below: Average Score Letter Grade 90 - 100 A 80 - 89 B 70 - 79 C 60 - 69 D Below 60 F The program asks the user to enter N number of students. The program should display a letter grade for each student. The program should consist of the following methods: calcAverage - this method accepts N number of students as arguments and returns the array of the average scores for N students. determineGrade - this method should accept the array of the average scores as an argument and display the letter grade for each N student. Input: 3 90 80 70 80 67 88 77 98 67 The first line is the number of students, while the following line is the test score for each student. Expected Output: Grade: B Grade: C Grade: Barrow_forward
- An array name, can begin with a number. Select one: True Falsearrow_forwardThe arrays array1 and array2 each hold 25 integer elements. Write code that copies the values in array1 to array2.arrow_forwardpython: numpy def purchases(transactions): """ QUESTION 7 - A high-end store is trying to evaluate the total amount that customer's spend per transaction. They want customers to spend anywhere between $130 and $150 on average. - You need to determine whether the average number spent on each transaction per month is above, between, or below the desired amount. - Transactions is a numpy array containing a date, total amount earned each month, and total number of transactions each month. - Above: month's average amount spent per transaction > 150 - Within Range: 150 >= month's average amount spent per transaction >= 130 - Below: month's average amount spent per transaction < 130 - Return a numpy array with "Above", "Within Range" and "Below" for the average amount spent per transaction per month - THIS MUST BE DONE IN ONE LINE HINT: use np.where() and convert the type of each column to float Args: transactions…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:CengageMicrosoft 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
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,