Question

Process Create a City structure. The structure will hold the name of a city and its temperature. In the main function, read i
Single Sign-on τ Tsu D Texan D DuckTrax D GoLive DLT.s DLTS Helpdesk D office 365瘟OreOne Cleveland 78 25.56 In the main funct
using C
Process Create a City structure. The structure will hold the name of a city and its temperature. In the main function, read in a series of city names and their temperature expressed in Fahrenheit. Store the data in an array of City structures. Stop reading when either: The user enters the word "quit" for a city name, or The size of the array is about to be exceeded. Create a function that determines the highest temperature of the cities. Pass it the array of City structures and the number of valid elements in the array. It will still return the index of the highest temperature. Use this index in the main function to display the name of the city with the highest temperature and that temperature so that it is displayed similar to the following: Seattle has the highest temperature 87 Create a function that is passed a temperature in Fahrenheit and the returns the equivalent temperature in Celsius. The temperature should be passed as an integer and the Celsius value should be returned as a double. Use the following formula to perform the conversion: Celsius 5.0/9.0 (Fahrenheit-32) Create a display function that displays a row for each city in the array similar to the following where the first number is the temperature in Fahrenheit and the second number is the temperature in Celsius: Select an area to comment orn aya 2018...-9 Lab 27-Structures.pd DOLL
Single Sign-on τ Tsu D Texan D DuckTrax D GoLive DLT.s DLTS Helpdesk D office 365瘟OreOne Cleveland 78 25.56 In the main function write code to produce output similar to the following by calling the previous functions: Enter city: Cleveland nter temperature: 78 Enter city: Enid Enter temperature: 65 Enter city: Miami Enter temperature: 98 ter city: quit liami has the highest temperature 98hF City Fahrenheit Celsius Cleveland 78 65 98 25.56 18.33 36.67 id Miami Notice that the Celsius temperature is displayed with 2 digits to the right of the decimal point. Turn is your program as previously. 2018Lab 27-Structures.pd.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Below is the code:

#include<stdio.h>
#include<conio.h>
#include<string.h>

struct City
{
char name[10];
int temp;
float cl
};
typedef struct City NAME;
NAME cityname[10];

void main()
{
int n,i,max,loc;

void calculate(int N);
void maximum_ele(int N);
clrscr();
fflush(stdin);


do{
printf("\nEnter city : ");
fflush(stdin);
gets(cityname[i].name);

if(cityname[i].name == 'quit')
   break;
n++;

printf("Enter temperature : ", i+1);
scanf("%d",&cityname[i].temp);

}while(cityname[i]!='quit');

maximum_ele(n);/* Function call */


calculate(n); /* Function call */


}

void calculate(n){


printf ("City \t Fahrenheit \t Celsius\n");
printf("\n-----------------------------\n");
/* Display the city and its values */
for(i=0;i<n;i++)
{

cityname[i].cl = (cityname[i].temp - 32) / 1.8;
printf("%-10s\t%3d\n",cityname[i].name,cityname[i].temp,cityname[i].cl);

}

void maximum_ele(N){
max= cityname[0].temp;
for(i=0;i<n;i++)
{
if(cityname[i].temp>max)
{
max=cityname[i].temp;
loc = i+1;
}
}
printf(" %d has the hihest temperature %d.\n", cityname[loc].temp, max);
}

Add a comment
Know the answer?
Add Answer to:
Process Create a City structure. The structure will hold the name of a city and its temperature. ...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Programming: Create a class called City with two public variables: a string to store the name...

    Programming: Create a class called City with two public variables: a string to store the name of the city and a float to store the average temperature in Fahrenheit. Create one object of the class that you create and ask the user to enter the city name and the average temperature in Fahrenheit. Store these in the object of the class that you create. Then display the contents of the class. Once that is working, make the variables private and...

  • using C language Create an array of doubles with 5 elements. In the array prompt the...

    using C language Create an array of doubles with 5 elements. In the array prompt the user to enter 5 temperature values (in degree Fahrenheit). Do this within main. Create a user defined function called convert2Cels. This function will not return any values to main with a return statement. It should have parameters that include the temperature array and the number of elements. The function should convert the values for Fahrenheit to Celsius and save them back into the same...

  • Can you help me to create this program, please? Prompt the user for the user for...

    Can you help me to create this program, please? Prompt the user for the user for a number of degrees in Fahrenheit as an int. That number should be passed to a function named ffocREFO. This function will do the necessary calculation to convert the passed temperature to degrees Celsius as a double. The function MUST have a void return type and have the following prototype: void ffccREF(double& celsius, int Faren); In your main, display both the entered temperature and...

  • c++ please 2. (50 points) Create a Temperature class that internally stores a temperature in degrees...

    c++ please 2. (50 points) Create a Temperature class that internally stores a temperature in degrees Kelvin as a double. Create mutator functions named setTempKelvin, setTempFahrenheit, and set TempCelsius that take an input temperature in the specified temperature scale (i.e. Kelvin, Fahrenheit, and Celsius, respectively), and convert the temperature to Kelvin, and store that temperature in the class member private variable (only in Kelvin, no other scales). Also, create functions that return the stored temperature in degrees Kelvin, Fahrenheit, or...

  • Create a class in Java with instance variables to hold the name, street address, city, and...

    Create a class in Java with instance variables to hold the name, street address, city, and state for a user. These instance variables should be private. You should enter the name and address in the nameAddress method. You should enter the city and state in the cityState method. In the main method, print the complete address using the method printAddress. You should not use the static keyword except for the main method. Your output should be similar to the output...

  • In this project you will create a console C++ program that will have the user to...

    In this project you will create a console C++ program that will have the user to enter Celsius temperature readings for anywhere between 1 and 365 days and store them in a dynamically allocated array, then display a report showing both the Celsius and Fahrenheit temperatures for each day entered. This program will require the use of pointers and dynamic memory allocation. Getting and Storing User Input: For this you will ask the user how many days’ worth of temperature...

  • Create a Python list (use first three letters of your name followed by the letter L...

    Create a Python list (use first three letters of your name followed by the letter L as the name of the list.) with the following data: 10, 20.0, 50.00, 7000, 7500, 7700, 7800, 8000, 9000, ‘python’. Display the entire list with an appropriate message. Display the 4th element in the list with an appropriate message. Display the first 3 values of the list only. Display all the values starting from the sixth element to the end of the list. Change...

  • Create a class called Student. This class will hold the first name, last name, and test...

    Create a class called Student. This class will hold the first name, last name, and test grades for a student. Use separate files to create the class (.h and .cpp) Private Variables Two strings for the first and last name A float pointer to hold the starting address for an array of grades An integer for the number of grades Constructor This is to be a default constructor It takes as input the first and last name, and the number...

  • C# Temp. Converter program. Create a Celsius and Fahrenheit Temperature Converter application. The application must have...

    C# Temp. Converter program. Create a Celsius and Fahrenheit Temperature Converter application. The application must have 2 Labels (each one of them assigned only to Celsius and Fahrenheit), 2 TextBoxes (each one of them assigned only to Celsius and Fahrenheit), only 1 Convert Button, 1 Clear Button, and 1 Exit Button. Also, 1 Error message label which will display the error messages. The application should only allow the user to enter the desired temperature just in one of the TextBoxes...

  • Array-based Queue Lecture 6 Two Class Exercises | Class Exercise #1 - Create an array-based queue that holds value...

    Array-based Queue Lecture 6 Two Class Exercises | Class Exercise #1 - Create an array-based queue that holds values of double data type. 1.) Create a program that produces the following output OUTPUT: Q Quit Enter your choice: e Enter an item: 1.1 E Enqueue D Dequeue s-show queue ← showMenuO function called in main) OQuit // screen clears-.. continue enqueuing.screen clearing with each iteration Enter your choice: e Queue is full. E Enqueue D Dequeue s Show queue 0...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT