12.1994 Gas Prices
In the student sample programs for this book, you will find a text file named 1994_Weekly_Gas_Averages.txt. The file contains the average gas price for each week in the year 1994. (There are 52 lines in the file. Line 1 contains the average price for week 1, line 2 contains the average price for week 2, and so forth.) Write a
- Display the lowest average price of the year, along with the week number for that price, and the name of the month in which it occurred.
- Display the highest average price of the year, along with the week number for that price, and the name of the month in which it occurred.
- Display the average gas price for each month. (To get the average price for a given month, calculate the average of the average weekly prices for that month.)
Want to see the full answer?
Check out a sample textbook solutionChapter 7 Solutions
Starting Out with Java: Early Objects (6th Edition)
Additional Engineering Textbook Solutions
Java: An Introduction to Problem Solving and Programming (8th Edition)
Starting Out with Programming Logic and Design (4th Edition)
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Modern Database Management (12th Edition)
Java How To Program (Early Objects)
Problem Solving with C++ (9th Edition)
- Instead of using parallel arrays, use an array of structs and redo assignment 8as follows:struct candidateType {string name;int numVotes;double percent;};Write a program vote.cc that allows to read from a file vote.in the last names ofthe candidates in an election and the number of votes received by each candidate. Theprogram should then output each candidate’s name, the number of votes received, and thepercentage of the total votes received by the candidate in descending order. Your programshould also output the winner of the election. A sample output is:Candidate Votes Received % of Total VotesJohnson 6000 31.09Brown 5000 25.91Miller 4000 20.73Duffy 2500 12.95Robson 1800 9.33Total 19300The Winner of the Election is JohnsonYour program should have and use at least the following functions:(a) Write a function openFile that prompts a user to enter a file name and opens it.(b) Write a function closeFile that closes an open file.(c) Write a function getData that reads from the file the…arrow_forwardAHPA #12: Movie Titles & Star Wars * * From a data file ("Lesson 14 - Movie Data"), read in data for Year, Total Gross, %± LY, Releases, Average, #1 Release for the years 1977 to 2019. * * I have decided that longer movie titles make more money. Add up the average income for each movie length and then print it out. * * * Tell me which movie length made the most money. * * Create an array that uses pointers to store each of the Star Wars movie titles. Once created, print out a of the movie titles in the array. *(use c) * #include <stdio.h> int main(void) { while (fgets (str, MAX_LEN, movieReleases ) != NULL ) { sscanf(str,"%d %f %d %d %[^\n]s",&year,&total,&releases,&average,&title); return 0;}arrow_forwardWrite a void function called largerThanLast whose heading is given below. The function should print all the numbers in the array which are larger than the last element in the array. arraySize represents the number of elements in the array. void largerThanLast (int List[ ], int arraySize)arrow_forward
- C++ 2D ARRAY, Continue this codes and change the array to seat[6][6]. Include a loop that asks the user if he wants to try again or no. If the user enters the reserved seat again then display "this seat is taken already". Upon trying again, the reserved seat displayed as (X) must be displayed. My Code: #include <iostream> using namespace std; int main() { cout << "Bus Seats:\n"; cout << "* A B C D\n" << "1 * * * *\n" << "2 * * * *\n" << "3 * * * *\n" << "4 * * * *\n"; char seat[5][5]; int row, column; char col; cout << "Enter the row of your selected seat: "; cin >> row; cout << "Enter the column of your selected seat: "; cin >> col; for(int i=0; i<5; i++){ for(int j=0; j<5; j++){ if(i==0){ switch (j) { case 0: seat[i][j]='*'; break; case 1: seat[i][j]='A'; break; case 2: seat[i][j]='B'; break; case 3: seat[i][j]='C'; break; case 4: seat[i][j]='D'; break; } } else if (j==0) { switch(i) { case 1: seat[i][j]='1';…arrow_forward1) Write a function called initializeArray that receives an array, its size, and two integers andinitializes the array with random values between the first integer and the second integer. Write anotherfunction called printArray that receives an array and its size and prints the array elements in a column. Writea test program that declares and initializes an array of size 20 with random values between 0 and 10 inclusive,and then prints the array using the above functions. 2). Write a function called evenOdd that receives an integer and determines if it is even or odd.Write a test program that initializes an integer array of size 50 with random integers between 1 and 99 inclusive using initializeArray (from question 1) and determines and displays the number of odd or evennumbers in the array using evenOdd.arrow_forward(CP6) Write a function that is passed an array of structs and performs calculations. The function should locate the highest gpa from a group of students. The function is passed the array of structs, the first element to be searched, and the last element to be searched. The return value of the function is the highest gpa in the search range. struct data{ string name; double gpa;}; double highestGpa( data [ ], int, int ); data [ ] - array of structs to search int - first element to be searched int - last element to be searched return - highest gpa from grouparrow_forward
- Date Printer Write a program that reads a char array from the user containinga date in the form mm/dd/yyyy. It should print the date in the form March 12, 2014.arrow_forwardA file USPopulation.txt contains the population of the US starting in year 1950 and then each subsequent record has the population for the following year. USPopulation.txtDownload USPopulation.txt Write a program that uses an array with the file that displays these in a menu and then produces the results. This is not an Object Oriented Program but should be a procedural program, calling methods to do the following: 1: Displays the year and the population during that year 2. The average population during that time period (Add up the populations of all records and divide by the number of years). 3. The year with the greatest increase in population - print the year and that population and that amount. To figure this out, compare the difference in population before of say year 1950 and 1951, store that difference somewhere. Compare 1951 with 1952, find that difference. Is that difference greater than the stored difference? If so, move that the the maximum place. 4.…arrow_forwardC++ ************Comment code please************ Into two files, p1.h and p1.cpp, create a class called intList with the following members Private members: int *a // A pointer to the array into which the list values will be stored. int capacity; // memorialize the capacity of the list int size; An integer “pop” to record the number of entries in the list Public members: constructor intList(int size) that causes the array to be sized at “size” entries, with a default size of 100 destructor ~intList() that deletes the dynamically allocated array “a” bool insert(int v) – inserts the value v at the beginning of the list; all other entries shift right. Returns true if v was inserted; otherwise, it returns false. bool add(int v) – inserts the value v at the end of the list. Returns true if the value was inserted; otherwise, it returns false. bool insertAt(int v, int index) – inserts the value v at the index “index”; values at that position need to shift right. Returns true if the…arrow_forward
- Create an indexception value of unique consonants and unique vowels.This is the Input: String of the name that was given below. It must be case sensitive.Steps:Step A: In every unique vowel of a name, you need to get the first index of that vowel from the original string.Step B: In each vowel index you get from step A, you will get the unique consonant from that position. if the index is out of scope of the consonant array, ignore that vowel index.Step C: In each unique consonant that you get from step B, you need to get the first index of that consonant from the original string.Step D: You will the value of indexception by adding all index you get from step C.output must be like this: > 2 lists that consist of unique vowels and unique consonants> vowel, the vowel index, the consonant, the consonant indexfinal ouput> total indexception value of the name that was given. ------Input "Tricia O. Reyes"Output:Name: Tricia O. ReyesVowels: ['a', 'e', 'i', 'o']Consonants: ['T', 'r',…arrow_forwardCreate a class Student that contains three members: roll no, name and mark, and threefunctions. Write a first inputStudent() function to get data of student class. Write a secondgetMark() function that returns a student’s mark. Write a third display() function thatdisplays a student’s data. In a main() function, you need to declare 40 students and get dataof all students by using inputStudent() function. And also use a pointer array to keep allstudents by mark greater than 50 and display the searching data of each student in thatpointer array (Use the access operator -> to access a pointer points to member functions ofthe Student class)arrow_forwardA1: File Handling with struct C++ This program is to read a given file and display the information about employees according to the type of employee. Specifically, the requirements are as follows. Read the given file of the information of employees. Store the information in an array or arrays. Display all the salaried employees first and then the hourly employees Prompt the user to enter an SSN and find the corresponding employee and display the information of that employee. NOTE : S- salaryemployee , H- Hourly employee S 135-25-1234 Smith Sophia DevOps Developer 70000H 135-67-5462 Johnaon Jacob SecOps Pentester 30 60.50S 252-34-6728 William Emma DevOps DBExpert 100000S 237-12-1289 Miller Mason DevOps CloudArchitect 80000S 581-23-4536 Jones Jayden SecOps Pentester 250000S 501-56-9724 Rogers Mia DevOps Auditor 90000H 408-67-8234 Cook Chloe DevOps QAEngineer 40 45.10S 516-34-6524 Morris Daniel DevOps ProductOwner 300000H 526-47-2435 Smith Natalie DevOps…arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT