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
Question
Chapter 12, Problem 2E
Program Plan Intro
Count number of poor family using “ArrayList”
Program Plan:
“Family.java”:
- Declare required variables.
- Define constructor for “Family” class.
- Assign “income” to new variable “newIncome”.
- Assign “size” to new variable “nSize”.
- Define method “isPoor” with two arguments “housingCost” and “foodCost”.
- This method returns “true” if the value of “housingCost + foodCost * size” is greater than half of income. Otherwise returns “false”.
- Define method “toString” which is used to returns the given statement with “size” and “income”.
“CountPoor.java”:
- Import required package.
- Define “CountPoor” class.
- Define main function.
- Create object for scanner class.
- Create array for “incomeValues” using “ArrayList”.
- Display prompt statement for number of families.
- Assign “additionalData” to “true”.
- Set “index” to “0”.
- Read income and size for each family using “while” loop.
- Display prompt statement for each family.
- If user input has next double, then
- Read income and size of each family from user.
- Add income values and size to “Family” class using “add” method.
- Otherwise, assign “additionalData” to “false” and then finish reading data from user.
- Display prompt statement for average housing cost and food cost.
- Read the average house cost and food cost from user.
- Initializes the count value to “0”.
- Compute the number of poor family using “for” loop.
- Check if the given family is poor by using “isPoor” function.
- If it is, then increment the count value and display poor family details using “get” method.
- Finally display the count of poor family.
- Define main function.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
(a). Consider that you are working as Data Analyst in an organization. The HR department needs you to carry out following operation on existing list of 10 employees name (you can assume 10 names in a list here).
Split the list into two sub-list namely subList1 and subList2, each containing 5 names.
A new employee (assume the name “Kriti Brown”) joins, and you must add that name in subList2.
Remove the second employee's name from subList1.
Merge both the lists.
Assume there is another list salaryList that stores salary of these employees. Give a rise of 4% to every employee and update the salaryList.
Sort the SalaryList and show top 3 salaries.
Write the Python code and output for the same.
(b). Design a program such that it converts a sentence into wordlist. Reverse the wordlist then. Write the code and output for the same.
Note: The code and its output must be explained technically. The explanation can be provided before or after the code, or in the form of…
Jelaskan perbedaan antara negasi, konjungsi, dan disjungsi dalam logika proposisi.
Perform the analysis workflow of the Chocoholics Anonymous product described in Appendix A.
Chapter 12 Solutions
Java: An Introduction to Problem Solving and Programming (8th Edition)
Ch. 12.1 - Suppose aList is an object of the class...Ch. 12.1 - Prob. 2STQCh. 12.1 - Prob. 3STQCh. 12.1 - Prob. 4STQCh. 12.1 - Can you use the method add to insert an element at...Ch. 12.1 - Prob. 6STQCh. 12.1 - Prob. 7STQCh. 12.1 - If you create a list using the statement...Ch. 12.1 - Prob. 9STQCh. 12.1 - Prob. 11STQ
Ch. 12.1 - Prob. 12STQCh. 12.2 - Prob. 13STQCh. 12.2 - Prob. 14STQCh. 12.2 - Prob. 15STQCh. 12.2 - Prob. 16STQCh. 12.3 - Prob. 17STQCh. 12.3 - Prob. 18STQCh. 12.3 - Prob. 19STQCh. 12.3 - Write a definition of a method isEmpty for the...Ch. 12.3 - Prob. 21STQCh. 12.3 - Prob. 22STQCh. 12.3 - Prob. 23STQCh. 12.3 - Prob. 24STQCh. 12.3 - Redefine the method getDataAtCurrent in...Ch. 12.3 - Repeat Question 25 for the method...Ch. 12.3 - Repeat Question 25 for the method...Ch. 12.3 - Repeat Question 25 for the method...Ch. 12.4 - Revise the definition of the class ListNode in...Ch. 12.4 - Prob. 30STQCh. 12.5 - What is the purpose of the FXML file?Ch. 12.5 - Prob. 32STQCh. 12 - Repeat Exercise 2 in Chapter 7, but use an...Ch. 12 - Prob. 2ECh. 12 - Prob. 3ECh. 12 - Repeat Exercises 6 and 7 in Chapter 7, but use an...Ch. 12 - Write a static method removeDuplicates...Ch. 12 - Write a static method...Ch. 12 - Write a program that will read sentences from a...Ch. 12 - Repeat Exercise 12 in Chapter 7, but use an...Ch. 12 - Write a program that will read a text file that...Ch. 12 - Revise the class StringLinkedList in Listing 12.5...Ch. 12 - Prob. 12ECh. 12 - Write some code that will use an iterator to...Ch. 12 - Prob. 14ECh. 12 - Write some code that will use an iterator to...Ch. 12 - Prob. 17ECh. 12 - Revise the method selectionSort within the class...Ch. 12 - Repeat the previous practice program, but instead...Ch. 12 - Repeat Practice Program 1, but instead write a...Ch. 12 - Write a program that allows the user to enter an...Ch. 12 - Write a program that uses a HashMap to compute a...Ch. 12 - Write a program that creates Pet objects from data...Ch. 12 - Repeat the previous programming project, but sort...Ch. 12 - Repeat the previous programming project, but read...Ch. 12 - Prob. 9PPCh. 12 - Prob. 10PPCh. 12 - Prob. 11PPCh. 12 - Prob. 12PPCh. 12 - Prob. 13PPCh. 12 - Prob. 14PPCh. 12 - Prob. 15PP
Knowledge Booster
Similar questions
- Encrypted email Assignment Download a software called pgp here: OpenPGP Email encryption. For all operating systems. Standing the test of time. OpenPGP Explain the process of creating a public and private key in the software in 2 paragraphs. In this assignment you will encrypt the body of an e-mail message and send me the encrypted message. I will decrypt the message providing you include a specific piece of information (what information should you also send with the email? Explain it in the email you encrypt. I will send you an encrypted response to the email and you will decrypt the message and upload it to black board along with the answers to the questions for this assignment. This is my public key: -----BEGIN PGP PUBLIC KEY BLOCK----- mQINBGVt7ioBEADBklX65xazdnhFZhMCs9bNzGVeVFggomPzx8xe/XtJ2infqb2d bEGICa5gLhDDP06ogACbRwpcuEFR8Fu4lO2jigWRvwrQ4eXiEVQIqTBxLFC7ClPz K0vCzQp5CXXBVk3MskkvDaF2yjVEkSGosjFKVZx76oe0+98AzJuMCDJujidy0pOW…arrow_forwardPlease help me Matlab don't use AIarrow_forwardMatlab help me quickly don't use AI pleasearrow_forward
- Please help me quickly don't use AI please Matlab provide screen for outputarrow_forwardPlease help I need output and screenarrow_forwardplease write Hack ALU Assembly program that will display the letters "C", "S", and the number 220 ( all formed by pixels ) in the nand2tetris CPU Emulator in the center of the screen in thecolor black. Please thanksarrow_forward
- Please help me do this exercisearrow_forwardDear expert already got wrong chatgpt answer No chatgpt will upvotearrow_forward3 ☐ ☐ ☐ ☐ Write a for loop that iterates 6 times. Each iteration: Put userNum to output. Then, put "-" to output. Then, assign userNum with userNum multiplied by 4. Ex: If input is 2, then output is: 2-8-32-128-512-2048- 1 integer userNum 2 integer i 3 4 // Program will be tested with inputs: 2 and 3 5 userNum = Get next input 6 7 Variables Not shown when editing 8 Your solution goes here 9 Code Flowchart 4arrow_forward
- Please fix this code it is supposed to display CS 220 with pixels at the center of the screen for the CPU Emulator in Nand2Tetris: CS220.ASM===================================================================================== @16640 // Load value 16640 into A register- starting pointD=A // Store value of A register (16640) in D register@address // Access memory location of address registerM=D // Store value of D into address register@count // load count memory locationM=0 // Initialize count value to 0 (LOOP) @6 // Load value 6 into A register ( total number of characters to write)D=A // Store value of A register (6) in D register@count // Access count memory locationD=M-D // Subtract current count value from 6@ENDLOOP // Jump to ENDLOOP if count >= 6D;JGE // If D >= 0 (count is greater than or equal to 6), jump to ENDLOOP @67 // load the ASCII code for 'C' (67) into the A registerD=A // store the…arrow_forwardPlease can you help me select the correct option in pythonarrow_forwardPlease could you helpe me answer this question in python. Ive tried the code that i attached but it was incorrectarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education