Concept explainers
Given the scores . txt file described in
Want to see the full answer?
Check out a sample textbook solutionChapter 4 Solutions
Absolute C++
Additional Engineering Textbook Solutions
Artificial Intelligence: A Modern Approach
Modern Database Management (12th Edition)
Problem Solving with C++ (10th Edition)
Starting Out with Java: Early Objects (6th Edition)
Starting Out with Programming Logic and Design (4th Edition)
Starting Out with C++: Early Objects
- A MyPetStore sells many pets and their accessories. As new pets are added to the MyPetStore, theirinformation is entered into a flat text file. Each month, the manager requests a listing of all pets sorted bytheir price. You must write a program to produce a report of MyPetStore and their types sorted by their pricesfrom the data in the flat text file. Below is a description of the information on the text file:• The first entry is the number of animals on the file (numeric) •The fields below repeat for each animal:o Pet name (String)o Birthdate (java.time.LocalDate)o Price (numeric)o Species Type (String)o Special feature (boolean or String)The animals sold by the MyPetStore are of six types: Dogs & Cats, Reptiles, Birds, Rabbits & SmallAnimals.For Dogs & Cats, the special feature field on the flat file is the breed of the animal (String).For Reptiles, the special feature field is the blood type (warm vs cold-blooded, String).For Birds, the special feature field is the…arrow_forwardC programming create a text base game to race 4 cars across the screen and determine the first second and third place. A text file (car.txt) with the name of the driver, type of the race car, car number, and the color of the car is given to you. In addition to the above, the user(s) should be asked if they want to modify their car’s specs. Such as the type of race car (Ford, Chevy, Dodge, etc.), the car number, name of driver, and the color. The user should be able to make changes to their vehicle between each race. The modifications are to be saved to a file. With each key press a random number between 0 and 10 is generated to represent the cars next distance to travel.arrow_forwardCreate a file in your project named employees.txt with the following data (you can simply create the file by hand rather than with Python code): 123 Bob Smith345 Anne Jones256 Carol Lee845 Steve Robert Anderson132 Jill Thompson From your program's main function, give the user the following options: lookup a name based on ID number, lookup an ID number based on name, and quit the program. OPTION 1: The user chooses to lookup a name based on ID number: Use a try/except and ask the user to enter an integer. If they don't enter an integer, print an error message. If they do enter an integer, call a function named lookup_employee which takes the id as a parameter. If an employee with the given id number is found, return the name. Otherwise, return the string “Employee not found” Back in main, print the return result. OPTION 2: The user chooses to lookup an ID based on name: Ask the user to enter the first and last name (don't ask for the middle name). Call a function named…arrow_forward
- In C++, my program reads from a file, each line of the text file ends in a 1 or 0. How do you make a function that updates the value in the text file to change to from 1 to 0 or 0 to 1?arrow_forwardThe 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_forwardTask: Loading data from files This exercise will require you to load some information from files and use it in your program. scene.txt contains a description of a series of shapes and colours to draw. You need to write code to read in the file data and draw the requested shapes in the correct colour. Each line in scene.txt will contain one of the following starting keywords followed by some data: COLOUR followed by 3 values: R, G, B CIRCLE followed by 3 values: X, Y, RADIUS RECT Followed by 4 values: X, Y, W, H LINE Followed by 4 values: X1, Y1, X2, Y2 CIRCLES are defined from the center. RECT's are defined from the top left. All values are space separated, and you can assume all input is correct (no errors). Please solve this program to draw the scene. I can't upload the file scene.txt, so I decide to screenshot a file for you. Subject: Java Programmingarrow_forward
- C++ Language Order Processing Order E 46 H 76 D 2 G 7arrow_forwardPlease write the code in carrow_forwardIn Python Write a program that consists of (at least) two function: A function that creates and saves data in a file. The saved data represents exam grades. In the function, you will create n random numbers in the range [0,100], where n is the number of students. The function can be called as follows: createFile(filename, n) Main function, in which the user inputs the file name and the number of students, then the main calls function createFile. The main should perform validation for n (should be > 0), and the filename (should end with .txt). I will explain how to validate strings in the coming lecture. Hint: a good developer will write four functions to solve the problem.arrow_forward
- IN JAVA Arrange the data for your chart in a text file as follows: The first line of the file is the title for the chart The second line of the file is the units used in the chart The rest of the file contains data values for the chart alternating with the label to print with the value on the preceding line. The program must be able to produce a chart from any data file arranged as described above. The name of the data file and the output file are provided on the command line. The program must check that there are enough command line arguments and stop with a suitable message if not. The program saves the chart to the output file (2nd command line argument); it may also display the chart to the terminal, but it is not required to. In addition to the above, accept two additional command line arguments: The maximum width for the chart (just the bar itself, not including the labels) The symbol to use for the barsarrow_forwardIn C language, create a program that uses a standardized input method (input file with From To and Weight defined) to read in a text file. The text file will contain the name of the building and the distance from each building when running the program with the file, the program will read the information above and will ask users which buildings are they in and where they want to go to find the shortest path. then it will display the shortest route and the distance from the building that the user is at to the building that the user wants to go toarrow_forwardDesign a program that reads a file called sales.txt containing the following data: Jane, 215.5,445.5,910.0 John, 825.0,250.5,675.0 Bill,0.0,999.15 Each line has a employee's name and their weekly sales totals all separated by commas. Some employees have taken vacation some weeks so no numbers are captured for those weeks. Create a function that takes a list of floats and returns the average value for those numbers. After reading the information from the file, use a for loop to calculate the sales average using your new average function for each employee and display the following output to the screen. Jane, average sales: 523.67 John, average sales: 583.50 Bill, average sales: 499.56arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning