Concept explainers
Using Files—Total and Average Rainfall
Write a
During the months of March–June, the total rainfall was 7.32 inches and the average monthly rainfall was 1.83 inches.
Data for the program can be found in the Rainfall. txt file located in the Chapter 5 programs folder on the book’s companion website.
Hint: After reading in the month names, you will need to read in rain amounts until the EOF is reached and count how many pieces of rain data you read in.
Want to see the full answer?
Check out a sample textbook solutionChapter 5 Solutions
Starting Out with C++: Early Objects (9th Edition)
Additional Engineering Textbook Solutions
Degarmo's Materials And Processes In Manufacturing
SURVEY OF OPERATING SYSTEMS
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Electric Circuits. (11th Edition)
- At a certain university, students have to submit their exams online. The administration decides that for each minute of late submission, 5 points are deducted. Write a program that asks the user for his initial grade and the late submission time (in minutes), and then displays the final result. Sample Run 1: Enter your initial grade: 82 Enter the late submission time (in minutes): 6 Your final grade is 52 Sample Run 2: Enter your initial grade: 115 Grades should be between 0 and 100 Sample Run 3: Enter your initial grade: 43 Enter the late submission time (in minutes): 10 Your final grade is 0 Sample Run 4: Enter your initial grade: 72 Enter the late submission time (in minutes): -2 Time should be positivearrow_forwardUse loop to solve this python program and use Error handling:IOError (File not found)arrow_forwardUse Pycharmarrow_forward
- Transient PopulationPopulations are affected by the birth and death rate, as well as the number of people who move in and out each year. The birth rate is the percentage increase of the population due to births and the death rate is the percentage decrease of the population due to deaths. Write a program that displays the size of a population for any number of years. The program should ask for the following data: The starting size of a population P The annual birth rate (as a percentage of the population expressed as a fraction in decimal form)B The annual death rate (as a percentage of the population expressed as a fraction in decimal form)D The average annual number of people who have arrived A The average annual number of people who have moved away M The number of years to display nYears Write a function that calculates the size of the population after a year. To calculate the new population after one year, this function should use the formulaN = P + BP - DP + A - Mwhere N is the…arrow_forwardStatistics are often calculated with varying amounts of input data. Write a program that prompts for and takes any number of non-negative integers as input, and outputs the average and max. A negative integer ends the input and is not included in the statistics. Example program run (the user types only the numbers, in this case 15 20 0 5 -1): Enter numbers separated by spaces, with a negative number to quit: 15 20 0 5 -1 Average = 10 Max = 20 #include <iostream>using namespace std;/* program that prompts for and takes any number of non-negative integers as input, and outputs the average and max. A negative integer ends the input and is not included in the statistics. Example program run (the user types only the numbers, in this case 15 20 0 5 -1): Enter numbers separated by spaces, with a negative number to quit:15 20 0 5 -1 Average = 10 Max = 20*/ int main() { /* Type your code here. */ return 0;}arrow_forwardusing python Filename for submission: bottles.py In many jurisdictions a small deposit is added to drink containers to encourage people to recycle them. In one particular jurisdiction, drink containers holding one liter or less have a $0.10 deposit, and drink containers holding more than one liter have a $0.25 deposit.Write a program that reads the number of containers of each size from the user. Your program should continue by computing and displaying the refund that will be received for returning those containers. Format the output so that it includes a dollar sign and two digits to the right of the decimal point. Don’t forget: Include a flowchart that describes your program’s operation (this will be counted as part of your grade as ‘documentation’ in the grading rubric) Sample outputarrow_forward
- Write a program that takes the birth year from the user and prints her/his age. Here are sample runs of the program: Sample 1: Enter your birth Your Age is: 42 years Sample 2: year: 1981 Enter your birth year: 2000 Your Age is: 23 years 3arrow_forwardWrite a program that queries information from three files(given to you). The first file contains the names and telephone numbers of a group of people. The second file contains the names and Social Security numbers of a group of people. The third file contains the names and annual income of a group of people. The groups of people should overlap. Your program should ask the user for a telephone number and then print the name, Social Security number, and annual income, if it can determine that information. Sample run1: Enter the phone number (7 digits, with a dash): 555-1234 555-1234 is associated with Bob Bob's SSN is 000300021 Bob's salary is 55000 Sample run2: Enter the phone number (7 digits, with a dash): 675-4566 Couldn't find a name associated with that number. Sample run3: Enter the phone number (7 digits, with a dash): 000-2345 000-2345 is associated with John John's SSN is 000000004 John's salary is 65000 python languagearrow_forwardJavaarrow_forward
- Could you write a C++ program for this that works.arrow_forwardWrite a program to process a collection of daily high temperatures. It will take 24 temperature values for one day. These values will be taken from user and will be in centigrade. Your program should count and print the number of hot days (high temperature 85 or higher), the number of pleasant days (high temperature 60–84), and the number of cold days (high temperatures less than 60). It should also display the category of each temperature and calculate the average temperature of the day and print it on the screen. Draw the flowchart of program.arrow_forwardIn this exercise you will write a program for printing out grade statistics for a university course. The program asks the user for results from different students on the course. These include exam points and numbers of exercises completed. The program then prints out statistics based on the results. Exam points are integers between 0 and 20. The number of exercises completed is an integer between 0 and 100. The program kees asking for input until the user types in an empty line. You may assume all lines contain valid input, which means that there are two integers on each line, or the line is empty. And example of how the data is typed in: Exam points and exercises completed: 15 87 Exam points and exercises completed: 10 55 Exam points and exercises completed: 11 40 Exam points and exercises completed: 4 17 Exam points and exercises completed: Statistics: Sample outputarrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning