Concept explainers
Write a
with a student’s first name then one space, then the student’s last name, then one space, then some
number of quiz scores that, if they exists, are separated by one space. The student will have between
zero and ten scores (inclusive), and each score is an integer between 0 and 100 (inclusive). The file
may or may not end with a new line character. Your program will read the data from this file and
write its output to a second file. The data in the output file (named average.txt) will contain the
student’s quiz scores followed by the average of the student’s quiz scores.
The output file must be formatted as described below.
1. Each quiz score should be listed in a right-justified column that is 4 characters wide. Note
that if a student has fewer than 10 scores (they have missed one or more of the quizzes), your
program will need to display the missing score(s) using 0 for each one.
2. The average should appear in its own column that is 10 characters wide. Note that if a student
has fewer than 10 scores, the average is still the sum of the quiz scores divided by 10.
3. The average should be computed with an accuracy of two decimal places.
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 5 images
- here is a text file containing the details of several invoices details. Each invoice uses 3 lines of the file. The first of the three lines is a string giving the date of the invoice, for example “1/5/2021” or “2/6/2021”. The second of the three lines contains double giving the amount, the third line is boolean indicating whether it is paid or not. However, the very first line of the file is an integer number, which says how many invoices are given in the file in the lines which follow it (i.e. how many records will follow). Text file example for two vehicles “invoices.txt” 2 1/5/2021 50.0 true 2/6/2021 20.0 false Write code for a method named processTextFile() which will open the file named ‘invoices.txt’, from which it will read the data of invoices. It will create Invoice objects using this data by calling the constructor that takes the parameters (date, amount, paid) , placing them into an ArrayList invoiceList.arrow_forwardGiven a text file food.txt containing the availability of food items. Write a program that reads the information from the text file and outputs the available food items. Add comments to better understand it txt.file content ========== Sandwiches Ham sandwich Classic ham sandwich Available Sandwiches Chicken salad sandwich Chicken salad sandwich Available Sandwiches Cheeseburger Classic cheeseburger Not available Salads Asian salad Mixed greens with ginger dressing, sprinkled with sesame Not available Beverages Water 16oz bottled water Available Vegetarian Avocado sandwich Sliced avocado with fruity spread Not available Mexican food Beef tacos Ground beef in freshly made tortillas Available Mexican food Chicken tacos Grilled chicken breast in freshly made tortillas Not available Beverages Coca-Cola 16oz Coca-Cola Availablearrow_forwardWrite a program that reads student's IDs and exam scores (type int) for a particular exam in a course from each line of an input file (the input file is included). You need to compute the average of these scores and assign grades to each student according to the following regulation: If a student's score is within 10 points (above or below) of the average, assign a grade of satisfactory. If a student's score is more than 10 points above average, the grade will be outstanding. If a student's score is more than 10 points below the average, the grade will be unsatisfactory. The output of your program should consist of a three-column table that shows each ID, score, and corresponding grade. A sample output is shown below. ID SOLS SENTO 0 1 2 3 4 8 9 Score 75 99 66 43 87 65 82 91 84 76 Grade Satisfactory Outstanding Unsatisfactory Unsatisfactory Outstanding Unsatisfactory Satisfactory Outstanding Satisfactory Satisfactory Write necessary functions and put them in a module to process this…arrow_forward
- Write a program that reads in from a file a starting month name, an ending month name, and then the monthly rainfall for each month during that period. As it does this, it should sum the rainfall amounts and then report the total rainfall and average rainfall for the period. For example, the output might look like this: 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.arrow_forwardThe Springfork Amateur Golf Club has a tournament every weekend. The club president has asked you to write a program that will read each player's name and score as keyboard input, and then save these as records in a file named golf.txt . First, the program should ask the user for the number of players. Then, it should ask the user for each name and score individually. The file golf.txt should be structured so that there is a line with the player's name, followed by their score on the next line. Here is an example: Emily 30 Mike 20 Jonathan 23 Look carefully at the following sample run of the program. In particular, notice the wording of the messages and the placement of spaces and colons. Your program's output must match this. Sample Run (User input shown in bold) Enter number of players :4↵ Enter name of player number 1 : Jimmy↵ Enter score of player number 1 : 30↵ Enter name of player number 2 : Carly↵ Enter score…arrow_forwardWrite a Python program for a simple quiz game. The questions and answers are stored in a text file named "questions.txt." Each line in the file represents a question and its corresponding options and correct answer in the format: "Question, Option1, Option2, Option3, Option4, CorrectOption." The program should load the questions from the file, present them to the user one by one, and keep track of their score. Allow the user to input their answer, and after completing the quiz, display their final score. Make sure to handle cases where "questions.txt" does not exist or has incorrect formatting. Use functions to structure your code, making it easier to understand and maintain. You can use a list or dictionary to store the questions and options. Ex: questions.txt: What is the capital of France?, Berlin, London, Paris, Madrid, 3 Who is the author of "To Kill a Mockingbird"?, Mark Twain, Harper Lee, J.K. Rowling, Ernest Hemingway, 2 What is the largest mammal on Earth?, Elephant, Blue…arrow_forward
- 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