Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Computer Science
C++
Create a text file "input.txt" with a certain amount of integers (you decide how many).
Write a program that reads these numbers from the file, adds them, and when you have reached the end of the file, calculates the average of these numbers. Print a message and the average to the console.
Code this program twice, demonstrating the two methods to detect the end of the file,
part A: reading a value from Instream and storing it (boolean expression) in the while loop
part B: using the eof() member function
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps with 3 images
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
- Input file is given like this: 4 4 XXXX XXX XXX X I need help in writing a code that read the integers then puts it in a variable for row and column. The first 4 is the amount of row, the second one is the amount of column.arrow_forwardwrite java programarrow_forwardPlease write a Java program , to write data into a file ( output.txt ). The output.txt file is below. 1 22 333 4444 55555 666666arrow_forward
- Write a program that reads a text file named as “input.txt” and performs the following operations:1. Write each word in the text file in reverse order to the file named as“output.txt” . (Example: If the text file contains ”Hello World!”, then itshould write to the output file ”olleH dlroW!”)2. Print the number of words.3. Print the number of words starting with a capital letter.4. Print the number of words that contain no characters other than Englishletters.In this challenge you are supposed to:1. Comment every function with a description explaining what it does andhow it does it.2. Research and learn how to read and write into text files by using properlibrary functions in C.In your program, you can assume that1. Both the input file (input.txt) and the output file (output.txt) will beplaced on the same folder as your program’s executable (.exe).2. In the input file, the length of the words will be at most 100.arrow_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_forwardWrite a python program that prompts the user for their favorite basketball team. It should be able to read the list of teams provided below in a file called favorite_teams.txt and check if their team is in that file. Teams in the file:JazzBullsMavericksSpursIf the team is in the file let the user know that their team is in the list of favorites. If the team is not in the file, add the team to the end of the file. Also, let the user know that their team will be added to the file.Sample Run in File:What is your favorite NBA team? Jazz [Enter]Your team Jazz is in the listFile before and after run: JazzBullsMavericksSpurs Sample Run not in File:What is your favorite NBA team? Pelicans [Enter]Your team Pelicans is not in the list. It will be added.File before run: JazzBullsMavericksSpursFile after run:JazzBullsMavericksSpursPelicansarrow_forward
- Use python 3.5 Please define main and invoke it.arrow_forwardExercise 6 : Given a text file containing numbers. Write a Python program that reads the text file line by line, and then calculates the number of even and odd digits in each line. At the end, your program should calculate the total number as well as the probability of even and odd numbers throughout the file, as shown in Figure 3. Input text file 12 3 4 56 78 2 39 89 34 56 73 900 12 45 67 23 90 11 1 12 34 56 77 2 Program output: In line 1 there are In line 2 In line 3 there are In line 4 In total there are 19 even digits and 25 The probability of evens digits is: 0.43. The probability of evens digita is: 0.57. 5 even digits and 6 odd digits. odd digits. 7 odd digits. even digits and 5 odd digita. odd digits. even digita and even digits and there are there are Figure 3. Input text file and Program outputarrow_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
- Write a program that takes a filename as input from the user and looks for lines of the form and extract the number from each of the lines using a regular expression. Compute the average of the numbers and print out the average as an integer. Example: Enter filename: mbox.txt38549arrow_forward1. Write a Java program that reads the file "input.txt" and calculates and prints the average of all integer numbers in this file. SAMPLE OUTPUT: throws FileNotFoundException try/catch OUTPUT SAMPLE #1 for input.txt: 1 2 3 4 5 6 x x x 8 12 x x 34 x x 10 20 Please input the name of the file to be opened: input.tx --- File Not Found! OUTPUT SAMPLE #1 for input.txt: 1 2 OUTPUT SAMPLE #2 for input.txt: 1 2 3 4 5 6 x x x 8 12 x x 34 x x 10 20 Please input the name of the file to be opened: input.txt Number # 1 is: 1 Number # 2 is: 2 3 4 5 6 x x x 8 12 x x 34 x x 10 20 Number # 1 is: 1 Number # 2 is: 2 Number # 3 is: 3 Number # 4 is: 4 Number # 5 is: 5 Number # 6 is: 6 Number # 3 is: 3 Number # 4 is: 4 Number # 5 is: 5 Number # 7 is: 8 Number # 8 is: 12 Number # 9 is: 34 Number # 6 is: 6 Number # 10 is: 10 Number # 7 is: 8 Number # 11 is: 20 The average of 11 numbers/file = 9.55 Number # 8 is: 12 Number # 9 is: 34 Number # 10 is: 10 OUTPUT SAMPLE #2 for Number # 11 is: 20 The average of 11…arrow_forwardWrite a program that inputs a filename from the user and prints to the terminal a report of the wages paid to the employees for the given period. The report should be in tabular format with the appropriate header. Each line should contain an employee’s name, the hours worked, and the wages paid for that period. The wages paid are equal to the hourly wage * hours worked + tips. Use the sample data using python: Berg 7.25 32 110.75 Turner 8.00 40 0 Roman 10.0 50 0 Pugh 7.25 32 22.75 Potter 8.75 20 0 Savage 9.50 40 55.0arrow_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