![Absolute C++](https://www.bartleby.com/isbn_cover_images/9780133970784/9780133970784_largeCoverImage.gif)
Absolute C++
6th Edition
ISBN: 9780133970784
Author: Walter Savitch, Kenrick Mock
Publisher: Addison-Wesley
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 2, Problem 12PP
Program Plan Intro
1.inputStream variables used tostream file data.
2.while() loop is used to count total number and total leading number.
Program description:
The main purpose of the program is to test Benford’s Law. Read all the number from file then present the output of the percentage of the leading digits from the total numbers.
Expert Solution & Answer
![Check Mark](/static/check-mark.png)
Want to see the full answer?
Check out a sample textbook solution![Blurred answer](/static/blurred-answer.jpg)
Students have asked these similar questions
Generating statistics from a set of data is a task that computers love. In this assignment, you will be implementing a grade processing system that will
generate the mean and standard deviation for a set of final exam grades.
We will assume that final grades are stored in a list, where each entry in the list is a string with the following format:
"studentNum-finalGrade%"
The string represents the final exam mark (finalGrade) that the student (studentNum) achieved. For example, the cell below contains a list of final exam marks
from two students. Student 1007089 achieved a mark of 91%, and student 1009989 achieved a mark of 77.5%.
grades = ['1007089-91%','1009989-77.5%' ]
We want to calculate the mean final exam mark from a list of grades. If we assume that we have N grades, the mean x can be calculated from the following
formula:
N-1
1
(1)
i=0
The variable x; represents each grade in our list at index i. We assume that we start counting at 0.
We also want to be able to calculate the…
A large company pays its salespeople on a commission basis. The salespeople receive $200 per week plus
9% their gross sales for that week. For example, a salesperson who sells $5,000 worth of merchandise in a
week receives $200 plus 9% of $5,000, or a total of $650. You’ve been supplied with a list of the items
sold by each salesperson. The values of these items are shown in the table below. Develop a Java
application that inputs one salesperson's items sold for last week and calculates and displays that
salesperson's earnings. There is no limit to the number of items that can be sold.
Item
Value
239.99
2
129.75
3
99.95
4
350.89
Objectives
This assignment was designed to reinforce programming concepts from Chapter 4. In this assignment you will practice:
• Using if-else statements
Sample Runs
Run:
Run:
Enter number sold of product #1: 20
Enter number sold of product #2: 30
Enter number sold of product #3: 0
Enter number sold of product #4: 45
Earnings this week: $2403.41
Enter number…
You are given a list of projects and a list of dependencies (which is a list of pairs of projects, where the second project is dependent on the first project). All of a project's dependencies must be built before the project is. Find a build order that will allow the projects to be built. If there is no valid build order, return an error.EXAMPLEInput:projects: a, b, c, d, e, fdependencies: (a, d), (f, b), (b, d), (f, a), (d, c)Output: f, e, a, b, d, c
Chapter 2 Solutions
Absolute C++
Ch. 2 - It is difficult to make a budget that spans...Ch. 2 - You have just purchased a stereo system that cost...Ch. 2 - Suppose you can buy a chocolate bar from the...Ch. 2 - Write a program that finds and prints all of the...Ch. 2 - In cryptarithmetic puzzles, mathematical equations...Ch. 2 - Buoyancy is the ability of an object to float....Ch. 2 - Write a program that calculates the total grade...Ch. 2 - Write a program that finds the temperature, as an...Ch. 2 - (This is an extension of an exercise from Chapter...Ch. 2 - Create a text file that contains the text I hate...
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 an activity that takes the list of hours and then returns the total weekly wage. Listing hours are arranged chronologically, ordered from Monday to Sunday. An employee earns $ 10 an hour for the first 8 hours. For each hour of overtime, you earn $ 15. On weekends, the employer pays twice as much as usual, no matter how many hours worked earlier in the week. For example, 10 hours worked during the week can cost 80 + 30 = $ 110, but over the weekend you will pay 160 + 60 = $ 220. Examples Weekly salary ([8, 8, 8, 8, 8, 0, 0]) 400 Weekly salary ([10, 10, 10, 0, 8, 0, 0]) → 410 Weekly salary ([0, 0, 0, 0, 0, 12, 0]) - 280 Settle on Rubyarrow_forwardWrite a program that generates a square table that contains randomly generated integer values that are between 0 and10. - include a fixed seed value by using the function random.seedarrow_forwardThere is only one list of N ingredients in the menu. Every ingredient has its beauty value that does not depend on its taste, but on the way it looks, which is expressed as a positive integer. To order a dish, the customer asks Ramsay to use all the ingredients from L to R (L is strictly less than R). Ramsay knows that the dish will be tasty and not only beautiful if the sum of its ingredients' beauty values is divisible by K. Ramsay does not want to use all the ingredients, so he always excludes one of them. Which one? - The least beautiful one! (in other words - which has the minimal beauty value). Now he wonders - how many segments (L,R) are there such that the sum of their beauty values will be divisible by K after excluding the least beautiful ingredient. Your assignment is to develop a python code that prints the answer for the problem. Sample test case are given below:Input:3 21 2 3Output:1arrow_forward
- KNN is a technique used to estimate new values based on the similarity of known ones. In this assignment, your company wants you to estimate the selling price of a customer's building The price you calculate will be given to the customer as the company selling price recommendation. You decide to use Data Science techniques such as the K-Nearest Neighbor.(KNN) You will need to: Import the necessary libraries from your program. (You can use the model class sklearn.neighbors.KNeighborsClassifier, part of the package sci-kit-learn 1.1.1 (Links to an external site) or any other. Train/test the model with the data included in the module (cal_housing.tgz). The house you need to estimate the value for has the following properties: longitude: 120.75latitude: 39.34housingMedianAge: 35.5total rooms: 260totalBedrooms:120 population:540households: 12medianIncome:1.8 K BuildingValue: ? What is the recommended price? You need to provide the code, properly commented. You could use…arrow_forwardProblem You are given a table with n rows and m columns. Each cell is colored with white or black. Considering the shapes created by black cells, what is the maximum border of these shapes? A shape is a set of connected cells. Two cells are connected if they share an edge. Note that no shape has a hole in it. Input format • The first line contains t denoting the number of test cases. • The first line of each test case contains integers n, m denoting the number of rows and columns of the matrix. Here, # represents a black cell and '.' represents a white cell. • Each of the next n lines contains m integers.arrow_forwardIterating over a dictionary example: Gradebook statistics. Write a program that uses the keys(), values(), and/or items() dict methods to find statistics about the student_grades dictionary. Find the following: Print the name and grade percentage of the student with the highest total of points. Find the average score of each assignment. Find and apply a curve to each student's total score, such that the best student has 100% of the total points. The language is in Python. # student_grades contains scores (out of 100) for 5 assignmentsstudent_grades = {'Andrew': [56, 79, 90, 22, 50],'Nisreen': [88, 62, 68, 75, 78],'Alan': [95, 88, 92, 85, 85],'Chang': [76, 88, 85, 82, 90],'Tricia': [99, 92, 95, 89, 99]} So far I have the first part of the question: for student, scores in student_grades.items(): print(student, sum(scores)/len(scores))arrow_forward
- Write a program that randomly fills in 0s and 1s into a 4-by-4 matrix, prints the matrix, and finds the first row and column with the most 1s. Here is a sample run of the program: 0011 0011 1101 1011 The largest row index: 2 The largest column index: 3arrow_forwardPython programmingarrow_forwardOne of the things discussed in this chapter is the sorting of data. Imagine that a large medical center hires you to write a program that displays a list of potential organ recipients. The hospital's transplant team will consult this list if they have an organ available for transplant. The hospital administrators have instructed you to sort potential recipients by last name and display them in alphabetical order. If more than 10 patients are waiting for a particular organ, the first 10 patients will be displayed; a doctor can either select one or move on to view the next 10 patients. You are concerned that this program will unfairly select patients whose last names begin near the front of the alphabet. It's critical that the hospital has a program written quickly, as the hospital currently has no method of going through potential organ recipients. Based on this, answer the following questions in detail: Would you write and install the program? If yes, would you change anything about…arrow_forward
- A young programmer wrote his first testing system. He was so happy it compiled that he invited his school friends to his own contest. But at the end of the tour it turned out that the system can't sort the teams in the results table properly. Help the programmer to write the correct implementation of the sorting. The teams should be sorted by the next criteria: 1) By the quantity of solved tasks in descending order 2) When the quantities of solved tasks are equal-by the penalty time in ascending order 3) When both quantities of solved tasks and penalty times are equal-by the indices of teams in ascending order. Output: n numbers - the indices of teams in sorted order. Example: Input 5 3 50 5 728 17 00 8 500 Output 52134arrow_forwardAp is of type Apple, the only values that it can be assigned (or can contain) are those defined by the enumeration. For example, this assigns:ap = Apple.RedDel; Write codearrow_forwardA basic wooden railway set contains the pieces shown in figure below. It identifies the quantityof each type of piece denoted by ‘x’. Each piece is not uniquely identified by a primary keyvalue only labeled by type. i.e., Input information only states quantity of types such as twelvestraight pieces, two branch pieces, two merge pieces, and sixteen curve pieces. Pieces connect the knob to opening, with subtend curves extending the arc from start to end by45 degrees, and the pieces can be flipped over for track direction. The task is to connect these pieces into a railway that has no overlapping tracks and no looseends where a train could run off onto the floor. Question: Suppose that the pieces fit together exactly with no slack. Give a precise formulation of thetask as a search problem. Write a Java algorithm to assemble optimally solving the problem.arrow_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
![Text book image](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
![Text book image](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
![Text book image](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
![Text book image](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
![Text book image](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
![Text book image](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education