Question
C programming: Using your favorite text editor, use the data on the next page to create a file which has a state/city string and a
C programming:
Using your favorite text editor, use the data on the next page to create a file which has a state/city string and a temperature for the city on each line such as: Arizona,Tucson:107 For any given state/city, there may be many lines in the file. The lines towards the bottom of the file represent the most recent temperatures. Write a program which does the following: 1. Prompts the user to enter the name of the input file; if the user does not enter a name, use a default file name, such as temperatures.txt 2. Reads the data from file into an ordered list of stacks. The list is sorted in ascending order by the state/city string, a unique key. The temperature values for a given state/city are pushed onto its stack. (See example below). The stack nodes contain o an integer (temperature) and o a pointer to the next stack node. The list nodes contain o a state/city string, o a pointer to the next state/city node, o a pointer to the previous state/city node, o a pointer to the stack of temperature nodes for that state/city, o a count of the nodes in the stack, and o a total of the temperature values in that stack. Requirement: circularly doubly-linked list with one sentinel node 3. Displays the sorted list in ascending order (state/city and only one temperature value at the top of the stack. (A Z) 4. Displays the sorted list in descending order (state/city and only one temperature value at the top of the stack. (Z A). 5. Search loop. Prompts the user for a state/city string. If the state/city string is in the list, display the most recent temperature and the average temperature for that state/city. Give an error message if the state/city string is not found in the list. Prompts the user repeatedly until s/he enters quit. EXAMPLE // input file Arizona,Tucson:99 Oregon,Portland:85 Arizona,Tucson:90 Oregon,Portland:75 Arizona,Tucson:100 // 2 nodes in the linked list: each node has its own stack {Arizona,Tucson, 289, 3} {Oregon,Portland, 160, 2} //stack top //stack top 100 75 90 85
INPUT FILE: temperatures.txt Pennsylvania,Philadelphia:91 California,San Francisco:75 Nevada,Reno:108 Arizona,Flagstaff:81 California,Yreka:101 Arizona,Tucson:107 California,Los Angeles:78 California,Los Angeles:81 Pennsylvania,Pittsburgh:89 Oregon,Salem:90 California,Los Angeles:82 Arizona,Flagstaff:84 California,San Francisco:64 Oregon,Salem:83 California,San Francisco:68 Arizona,Tucson:99 California,Yreka:100 Arizona,Phoenix:109 Oregon,Portland:82 Arizona,Tucson:103 Oregon,Portland:79 Arizona,Phoenix:107 California,Cupertino:88 California,San Francisco:82 Arizona,Tucson:109 Oregon,Salem:85 Pennsylvania,Philadelphia:86 California,Los Angeles:97 Nevada,Reno:108
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started