Java: An Introduction to Problem Solving and Programming (8th Edition)
8th Edition
ISBN: 9780134462035
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 7, Problem 2E
Write a
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
JAVAWrite a program that searches person's name and display all matched name. For example, if a user inputs the letter "Davis", the program searches all name which includes "Davis" in an array. Then, display all matched names on the screen. You must declare a single dimensional array which has all people’s name. Use methods of string class
For Beginners Java:
Write a program that ask the user to enter a list of positive scores until the user enters a negative score to terminate the input. You need to store these scores in an array.  You can assume the maximum number of scores the user may enter is 50. However, you need to keep track of the actual number of scores entered. Write 2 methods:
1. calculateAverage(): this method takes the list of scores and return the average score.
2. countPerfectScores(): this method takes the list of scores and return the number of perfect scores (100).
The main program reads the input and calls these methods and print the results.
Please make sure you write a comment line to document what your method does.
The assignment will be similar to an assignment used frequently in CS116 classes.
You will be given an integer array of positive numbers. Your program should process the array and do the following for each entry:
Determine if the number is odd or even.
Add to a counter for each type, i.e. an even counter and an odd counter.
Add the number to a sum for each type, i.e. a total of the odd numbers and a total of the even numbers.
A value of -999 indicates the end of the array. Your program should end at that point.
Â
The input will be the following variable in your program:
L3Array DCD 22,9,333,47,72,128,111,44,-999
The actual number of array entries and their values will be different when your program is graded. The last number will still be -999.
Â
The output of your program will be the counts and totals placed in the following variables:
L3OddCt DCD 0 ; count of odd numbers
L3OddTot DCD 0 ; total of odd numbers
L3EvCt DCD 0 ; count of even numbers
L3EvTot DCD 0 ; total of even…
Chapter 7 Solutions
Java: An Introduction to Problem Solving and Programming (8th Edition)
Ch. 7.1 - What output will be produced by the following...Ch. 7.1 - What output will be produced by the following...Ch. 7.1 - What output will be produced by the following...Ch. 7.1 - Consider the following array: int [] a = new...Ch. 7.1 - What is wrong with the following code to...Ch. 7.1 - Write a complete Java program that reads 20 values...Ch. 7.2 - Write some Java code that will declare an array...Ch. 7.2 - Rewrite the method displayResults of the program...Ch. 7.2 - What output will be produced by the following...Ch. 7.2 - Give the definition of a static method called...
Ch. 7.2 - Give the definition of a static method called...Ch. 7.2 - Prob. 12STQCh. 7.2 - The following method compiles and executes but...Ch. 7.2 - Suppose that we add the following method to the...Ch. 7.3 - Prob. 15STQCh. 7.3 - Replace the last loop in Listing 7.8 with a loop...Ch. 7.3 - Suppose a is an array of values of type double....Ch. 7.3 - Suppose a is an array of values of type double...Ch. 7.3 - Prob. 19STQCh. 7.3 - Consider the partially filled array a from...Ch. 7.3 - Repeat the previous question, but this time assume...Ch. 7.3 - Write an accessor method getEntryArray for the...Ch. 7.4 - Prob. 23STQCh. 7.4 - Write the invocation of the method selectionSort...Ch. 7.4 - How would you need to change the method...Ch. 7.4 - How would you need to change the method...Ch. 7.4 - Consider an array b of int values in which a value...Ch. 7.5 - What output is produced by the following code?...Ch. 7.5 - Revise the method showTable in Listing 7.13 so...Ch. 7.5 - Write code that will fill the following array a...Ch. 7.5 - Write a void method called display such that the...Ch. 7.6 - Prob. 33STQCh. 7.6 - Prob. 34STQCh. 7 - Write a program in a class NumberAboveAverage that...Ch. 7 - Write a program in a class CountFamiles that...Ch. 7 - Write a program in a class CountPoor that counts...Ch. 7 - Write a program in a class FlowerCounter that...Ch. 7 - Write a program in a class characterFrequency that...Ch. 7 - Create a class Ledger that will record the sales...Ch. 7 - Define the following methods for the class Ledger,...Ch. 7 - Write a static method isStrictlyIncreasing (double...Ch. 7 - Write a static method removeDuplicates(Character[]...Ch. 7 - Write a static method remove {int v, int [] in}...Ch. 7 - Suppose that we are selling boxes of candy for a...Ch. 7 - Create a class polynomial that is used to evaluate...Ch. 7 - Write a method beyond LastEntry (position) for the...Ch. 7 - Revise the class OneWayNoRepeatsList, as given in...Ch. 7 - Write a static method for selection sort that will...Ch. 7 - Overload the method selectionSort in Listing 7.10...Ch. 7 - Revise the method selectionSort that appears in...Ch. 7 - Prob. 18ECh. 7 - Write a sequential search of an array of integers,...Ch. 7 - Write a static method findFigure (picture,...Ch. 7 - Write a static method blur (double [] [] picture)...Ch. 7 - Write a program that reads integers, one per line,...Ch. 7 - The following code creates a small phone book. An...Ch. 7 - Write the method rotateRight that takes an array...Ch. 7 - The following code creates a ragged 2D array. The...Ch. 7 - Write a program that will read a line of text that...Ch. 7 - A palindrome is a word or phrase that reads the...Ch. 7 - Add a method bubbleSort to the class ArraySorter,...Ch. 7 - Add a method insertionSort to the class...Ch. 7 - The class TimeBook in Listing 7.14 is not really...Ch. 7 - Define a class called TicTacToe. An object of type...Ch. 7 - Repeat Programming Project 10 from Chapter 5 but...Ch. 7 - Prob. 8PPCh. 7 - Write a GUI application that displays a picture of...Ch. 7 - ELIZA was a program written in 1966 that parodied...Ch. 7 - Prob. 11PPCh. 7 - Create a GUI application that draws the following...Ch. 7 - Practice Program 2 used two arrays to implement a...Ch. 7 - Practice Program 5.4 asked you to define Trivia...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
State the order of evaluation of the operators in each of the following C statements and show the value of x af...
C How to Program (8th Edition)
Write a program to print the corresponding Celsius to Fahrenheit table.
C Programming Language
Write a function called to insert a new entry into a linked list. Have the procedure take as arguments a pointe...
Programming in C
Suppose you define a class in separate files and use the class in a program. Now suppose you change the class I...
Problem Solving with C++ (10th Edition)
Weight Loss If a moderately active person cuts their calorie intake by 500 calories a day, he or she can typica...
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
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
- Write a program in a class FlowerCounter that computes the cost of flowers sold at a flower stand. Five kinds of flowers—petunia, pansy, rose, violet, and carnation— are stocked and cost, respectively, 50¢, 75¢, $1.50, 50¢, and 80¢ per flower. Create an array of strings that holds the names of these flowers. Create another array that holds the cost of each corresponding flower. Your program should read the name of a flower and the quantity desired by a customer. Locate the flower in the name array and use that index to find the cost per stem in the cost array. Compute and print the total cost of the sale.arrow_forwardThe assignment will be similar to an assignment used frequently in CS116 classes. You will be given an integer array of positive numbers. Your program should process the array and do the following for each entry: Determine if the number is odd or even. Add to a counter for each type, i.e. an even counter and an odd counter. Add the number to a sum for each type, i.e. a total of the odd numbers and a total of the even numbers. A value of -999 indicates the end of the array. Your program should end at that point.  The input will be the following variable in your program: L3Array DCD 22,9,333,47,72,128,111,44,-999 The actual number of array entries and their values will be different when your program is graded. The last number will still be -999.  The output of your program will be the counts and totals placed in the following variables: L3OddCt DCD 0 ; count of odd numbers L3OddTot DCD 0 ; total of odd numbers L3EvCt DCD 0 ; count of even numbers L3EvTot DCD 0 ; total of even…arrow_forwardWrite a Java program named Findletter that asks the user to enter 10 letters and store them in an array. Then it should ask the user to enter a letter (char value) to search for it. Then, if the entered letter is found, the program should display the message "The letter is in the array", otherwise it should display the message "The letter is not in the array".arrow_forward
- Write a program that uses a two-dimensional array to store the highest and lowest temperatures for each month of the year. The program should output the average high, average low, and highest and lowest temperatures of the year. Your program must consist of the following methods: Â Method getData: This method reads and stores the data in the two-dimensional array. Â Method averageHigh: This method calculates and returns the average high temperature of the year. Method averageLow: This method calculates and returns the average low temperature of the year. Method indexHighTemp: This method returns the index of the highest temperature in the array. Method indexLowTemp: This method returns the index of the lowest temperature in the array.arrow_forwardProblem: We need a program that takes 8 products and makes calculations and informs the user. Products have name, type and cost. Write the program that takes name,type and cost information from the user and saves the product objects to an array and calculates the total cost, the one with the most cost and the one with the least cost. For example: Banana Fruit 10 Apple Fruit Trousers Textile 50 T-Shirt Textile 30 Pencil Office 15 Office Đ Đ°per Strawberry Computer 10 Fruit 20 Electronics 6000 Total Cost: 6140 TL Most Expensive: Computer Least Expensive: Applearrow_forward1. Write a program in a class EvensOddsAvg that counts the integers that are below the average. Read fifteen integers from the keyboard and place them in an array. Compute the sum and count of the evens and the odds separately. Find the average of the integers, and count and display the integers which are below average. Please Java Codearrow_forward
- Write a program that lets the user enter the total rainfall for each of 12 months (starting with January) into an array of doubles. Â The program should calculate and display (in this order): Â the total rainfall for the year, the average monthly rainfall, and the months with the highest and lowest amounts. Â Months should be expressed as English names for months in the Gregorian calendar, i.e.: January, February, March, April, May, June, July, August, September, October, November, December. Â Do not accept negative numbers for monthly rainfall figures. When a negative value is entered, the program outputs "invalid data (negative rainfall) -- retry" and attempts to reread the value. Â Â NOTE:Â Decimal values should be displayed using default precision, i.e. do not specify precision.arrow_forwardWrite a Java program to display three monthly sales of different vehicle types. The rows and columns represent the monthly sales of each vehicle type.JAN FEB MAR SUV 25 15 35 COUPE 25 55 35 SEDAN 11 20 45 VAN 17 27 25Using a Two-Dimensional array, produce the vehicle type sales report and the total sales made for each vehicle type. If the total sales made per month are greater than or equal to 100, gold status is awarded. If the monthly sales are less than 100, silver status is awarded.arrow_forwardWrite a java program: Question 1 Write a program that allows the user to enter name and grade until "QUIT" is entered for name. The grade should be a number between 0 and 100. If the user input of a grade is not in this range, you should ask the user to re-input the grade. Store all the names in an array called names, and all the grades in an array called grades. Print out all the names and the corresponding grades. For Example, Input Enter name: Alice Enter grade: 90 Enter name: Bob Enter grade: 80 QUIT Expected output Name: Alice, Grade: 90 Name: Bob, Grade: 80arrow_forward
- Write a program that takes numbers from the user and places them into an array. After each new entry from the user, the program prints out the current array of numbers. Several rules must be followed: Each new number is checked and added to the array ONLY if it is larger than the number in the previous position in the array. This condition is not checked for the first number.In other words, the new number is rejected and nothing is added to the array if the entry is too-small. The new number is added to the array EXCEPT:  when the user enters a number greater than 75, the number 0 is added to the array instead. when the user enters a multiple of 7 (and less than or equal to 75), the number 7 is added to the array instead.  The program exits after 10 numbers have been placed into the array.  Programming requirements: You must define and call at least one function. I recommend printArray(...) You must use at least one array. Assume the entries are integers Example Test Case:…arrow_forward2. A store owner wants the total sales for 2020. Write a program that will load an array with 12 months of sales. Use iomanip to make a nice-looking chart that shows the monthly sales, the month with the highest sales, lowest sales, and average for the year sales. January ……………. $50,000 February…………… $60,000 March ……………….$80,000 April ………………..$106,000 May …………………..$50,000 June ………………..$190,000 July ………………….$900,000 August …………… $102,000 September ………..$70,000 October …………..$700,000 November………… $90,000 December …………$90,000 Total Sales for the year 2020 was ………………….………$ The month with highest sales was ****** at ………..$ The month with lowest sales was ****** at ………...$ The average of sales for the year was ……………………$ C++arrow_forwardC1. Write a Java program named Counter that asks the user to enter 15 real numbers and store them in an array. Then it should find and display how many numbers are below 25 in the array. The user should enter ten numbers in response to a message. A sample run of the program: Enter 15 real numbers: 55 101 -44 39 17 99 0 42 11 37 61 -51 78 213 55.75 There are 5 numbers are below 25 in the array.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
9.1: What is an Array? - Processing Tutorial; Author: The Coding Train;https://www.youtube.com/watch?v=NptnmWvkbTw;License: Standard Youtube License