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
Additional Engineering Textbook Solutions
Starting Out with C++ from Control Structures to Objects (8th Edition)
Problem Solving with C++ (10th Edition)
Starting Out With Visual Basic (7th Edition)
Database Concepts (7th Edition)
Problem Solving with C++ (9th Edition)
Starting Out with Python (3rd Edition)
- PYTHON CODINGarrow_forwardI am confused on how to go about writing this python program.arrow_forwardA Company wants to produce a product orders report from its product orders file. Each record on the file contains the product number of the item ordered, the product description, the number of units ordered, the retail price per unit, the freight charges per unit, and the packaging costs per unit. Your algorithm is to read the product orders file, calculate the total amount due for each product ordered and print these details on the product orders report. The amount due for each product is calculated as the product of the number of units ordered and the retail price of the unit. A discount of 10% is allowed on the amount due for all orders over GHC100.00. The freight charges and packaging costs per unit must be added to this resulting value to determine the total amount due. Answer should be in pseudo codearrow_forward
- The manager of a football stadium wants you to write a program that calculates the total ticket sales after each game. There are four types of tickets—box, sideline, premium, and general admission. After each game, data is stored in a file in the following form: ticketPrice numberOfTicketsSold … Sample data are shown below: 250.75 5750 100.50 28000 50.25 35750 25.00 18750 The first value indicates that the ticket price is Php 250.75 and that 5750 tickets were sold at that price. Output the total number of tickets sold and the total sale amount using c++ compiler. Format your output with two decimal places.arrow_forwardIn python The text file “studentMarks.txt” has been provided for you. Each line contains the Last Name, First Name and 8 marks separated by spaces of a single student. For each student in the file, adjust the file to include the average of their top 6 marks, rounded to 1 decimal place, at the end of the line. For example, in the file, the line may say: Mars, Bruno 82 82 85 94 65 79 81 90 Afterwards, it should be updated to say: Mars, Bruno 82 82 85 94 65 79 81 90 Top6Avg: 85.7 Your program must define a function to determine the average of the top 6 marks. You may define more functions as needed for your program.arrow_forwardwrite a program in python Write a program that will allow a student to enter their name and then ask them to solve 10 mathematical equations. The program should display two random numbers that are to be added, such as: 247 + 129 The program should allow the student to enter the answer. The program should then display whether their answer was right or wrong, and accumulate the right values. After the 10 questions are asked, calculate the average that was correct. Then display the student name, the number correct, and the average correct in both decimal and percentage format. In addition to any system functions you may use, you might consider the following functions: A function that allows the student to enter their name. A function that gets two random numbers, anywhere from 1 to 500. A function that displays the equation and asks the user to enter their answer. A function that checks to see if the answer is correct and accumulates the number correct. A function that calculates the…arrow_forward
- 2. The manager of a basketball stadium wants you to write a program that calculates the total ticket sales after each game. There are four types of tickets – box, sideline, premium, and general admission. After each game, data is stored in a file in the following forms: ticketPrice numberOfTicketsSold Sample data are shown below: 250 5750 100 28000 50 35750 25 18750 The first line indicates that the box ticket price is 250 pesos and that 5750 Tickets were sold at that price. Output the number of the tickets sold and the total sale amount. Format your output with two decimal places.arrow_forwardSolve it in C language // use new method plsarrow_forwardJava Your program must read a file called personin.txt. Each line of the file will be a person's name, the time they arrived at the professor's office, and the amount of time they want to meet with the professor. These entries will be sorted by the time the person arrived. Your program must then print out a schedule for the day, printing each person's arrival, and printing when each person goes in to meet with the professor. You need to print the events in order of the time they happen. In other words, your output will be sorted by the arrival times and the times the person goes into the professor's office. In your output you need to print out a schedule. In the schedule, new students go to the end of the line. Whenever the professor is free, the professor will either meet with the first person in line, or meet with the first person in line if nobody is waiting. Assume no two people arrive at the same time. You should solve this problem using a stack and a queue. You can only…arrow_forward
- It is a complete question.arrow_forwardpython Write a program that uses a text file to store the days and hours that a user worked in a week. The program should begin by prompting for the number of days worked in the week. It should continue with a loop for input of the days and hours and for writing these to the file, each on its own line. Sample Output (inputs shown in boldface)How many days did you work this week? 5Enter day of week MondayHow many hours did you work on Monday? 10Enter day of week TuesdayHow many hours did you work on Tuesday? 8Enter day of week WednesdayHow many hours did you work on Wednesday? 12Enter day of week FridayHow many hours did you work on Friday? 12Enter day of week SaturdayHow many hours did you work on Saturday? 8File was createdarrow_forwardWrite a program that produces a bar chart showing the population growth of Prairieville, a small town in the Midwest, at 20 year intervals during the past 100 years. The program should read in the population figures (rounded to the nearest 1000 people) for 1910, 1930, 1950, 1970, 1990, and 2010 from a file. For each year it should display the date and a bar consisting of one asterisk for each 1000 people.arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning