Gas Prices
In the student sample program files for this chapter, you will find a text file named GasPrices.txt. The file contains the weekly average prices for a gallon of gas in the United States, beginning on April 5, 1993, and ending on August 26, 2013. Here is an example of the first few lines of the file’s contents:
04-05-1993:1.068
04-12-1993:1.079
04-19-1993:1.079
4-26-1993:1.086
5-03-1993:1.086
and so on …
Each line in the file contains the average price for a gallon of gas on a specific date. Each line is formatted in the following way:
MM is the two-digit month, DD is the two-digit day, and YYYY is the four-digit year. Price is the average price per gallon of gas on the specified date.
For this assignment you are to write one or more programs that read the contents of the file and perform the following calculations:
Average Price Per Year: Calculate the average price of gas per year, for each year in the file. (The file’s data starts in April, 1993, and it ends in August, 2013. (For the years 1993 and 2013, use only the data that is present for those years.)
Average Price Per Month: Calculate the average price for each month in the file.
Highest and Lowest Prices Per Year: For each year in the file, determine the date and amount for the lowest price, and the highest price.
List of Prices, Lowest to Highest: Generate a text file that lists the dates and prices, sorted from the lowest price to the highest.
List of Prices, Highest to Lowest: Generate a text file that lists the dates and prices, sorted from the highest price to the lowest.
You can write one program to perform all of these calculations, or you can write different programs, one for each calculation.
Want to see the full answer?
Check out a sample textbook solutionChapter 9 Solutions
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Additional Engineering Textbook Solutions
Thinking Like an Engineer: An Active Learning Approach (4th Edition)
Database Concepts (8th Edition)
Java: An Introduction to Problem Solving and Programming (8th Edition)
Thermodynamics: An Engineering Approach
Modern Database Management
Concepts Of Programming Languages
- Pendant Publishing edits multi-volume manuscripts for many authors. For each volume, they want a label that contains the author’s name, the title of the work, and a volume number in the form Volume 9 of 9. For example, a set of three volumes requires three labels: Volume 1 of 3, Volume 2 of 3, and Volume 3 of 3. Design an application that reads records that contain an author’s name, the title of the work, and the number of volumes. The application must read the records until eof is encountered and produce enough labels for each work. Design a flowchart and psuedocode Pendant Publishing.arrow_forward2. Big, Bigger, Biggest by CodeChum Admin Welcome to a game of Big, Bigger, and Biggest! The game where we give you three big numbers and you're going to choose which one is the biggest. Do your worst! Input 1. First integer Constraints This is guaranteed to be a whole number. 2. Second integer Constraints This is guaranteed to be a whole number. 3. Third integer Constraints This is guaranteed to be a whole number. Output The first line will contain a message prompt to input the first number.arrow_forwardswitch_player(): we will allow the players to choose their own names, but for our purposes, it is easier to think of them as number (0 and 1, for indexing purposes). We will display their names to them on the screen, but in the background, we will keep track of them based on their number. This function should take 1 argument, an integer (either 0 or 1) representing the player and should return the opposite integer (1 if 0 is entered and 0 if 1 is entered). This is a simple function, but it will make our code cleaner later. Use your constants! Using Thonnyarrow_forward
- check_game_over(): as the name suggests, this function should check to see if the game is over (if one side has no stones left in all of its pockets). It takes as an argument the game board and should return True if the game is over and False otherwise.arrow_forwardSearching for a student’s details and status. from this pseudocode startdeclarationsnum studentNumnum studentTempnum numOfStudentsnum maxOfStudents = 300num timeOfDaynum maxTemp = 38 degreesnum studentNumArray (maxStudents)String studentNameString studentStatusstring nameArray (maxStudents)string QUIT "ZZZ"while numOfStudents < maxStudentswhile quit <> "ZZZ" studentScreening()tempMonitor()timeMonitor()studentArray()numOfStudents = numOfStudents + 1studentSearchDetails()endwhileendwhilestop studentScreening()output "Enter student number"input studentNumoutput "Enter student name"input studentNameoutput " Student Temp"input studentTempoutput "Enter time"input "time"returntempmonitor()if studentTemp >maxTemp = 38 degreesoutput studentStatus = "Not Admitted"status = Not Admittedelsestatus = Admittedoutput studentStatus = "Admitted"end ifreturntimeMonitor()output "Enter Time of Screening"input timeOfDayif timeOfDay > 12status = "Not Admitted"output studentStatus =…arrow_forwardTruth table: Please make sure the truth table is correct and it has no mistakes. Correct the truth table if there are mistakes.arrow_forward
- the huntington high school basketball team has five players named art, bob, cal, dan, and eli. accept the number of points scored by each player in a game and create a bar chart that illustrates the points scored, similar to the chart in figure.arrow_forwardOutput Specification The program prints out the total Calories of the selected meal, and stops executing after this output. Sample Input Соpy 1. Sample Output Сopy Your total Calorie count is 649. Explanation The customer chose Burger #2, Side #1, Drink #3 and Dessert #4.arrow_forwardRoad Trip Programming challenge description: You've decided to make a road trip across the country in a straight line. You have chosen the direction you'd like to travel and made a list of cities in that direction that have gas stations to stop at and fill up your tank. To make sure that this route is viable, you need to know the distances between the adjacent cities in order to be able to travel this distance on a single tank of gasoline, (No one likes running out of gas.) but you only know distances to each city from your starting point. Input: Your program should read lines from standard input. Each line contains the list of cities and distances to them, comma delimited, from the starting point of your trip. You start your trip at point 0. The cities with their distances are separated by semicolon. Output: Print out the distance from the starting point to the nearest city, and the distances between two nearest cities separated by comma, in order they appear on the route. Test 1…arrow_forward
- Assignment #2 Design an application to search in a database table of employee records. Each employee record consists of an ID, first name, last name, job title. The user interface should look similar to the sketch shown below. A text field is used to input the search query. A combo box is used to choose the search criteria (e.g. search by ID, search by first name, search by last name). By choosing any criteria and clicking on the "search" button, the correct results should be shown on the "results" pane. Search Query Search criteria Search Results Item1 Item2 Item3 otes E Notes Comments 2:38 PM ENG 3/8/202arrow_forward3. Randomly generate a number in range [1, 12]. Map this number to a season: if the number is 3, 4, or 5, map it to “Spring", if the number is 6, 7, or 8, map it to "Summer", if the number is 9, 10, or 11, map it to "Fall", and if the number 12, 1, or 2, map it to "Winter". Display season namearrow_forwardthree textbox arrays A1, A2, A3 contains degrees of 10 students in * three materials. The code to find the average of each student is blä 5 Fori=0 to 9 For i=0 to 9 S={val(A1(i).text)+ val(A2(i).text)+ S=S+(val(A(i).text)/3 |val(A3(i).text))/3 Form1.print S Form1.printS Nexti Nexti the Code is The code is Fori=0 to 9 For i=0 to 9 S=S+(val(A(i).text) S=S+(val(A1(i).text)+ val(A2(i).text)+ |val(A3(i).text))/3 Form1.print S Form1.printS Nexti Nexti Av=S/3 the code is The Code isarrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT