You can vary it as long as the fahr and cels temperatures line up vertically and everything is clearly labeled.
#include <iostream> #include <iomanip> using namespace std; double fahrenheitToCelsius(double F){ return (F - 32) * 5 / 9; } void inputTemp(double fTemp[], double cTemp[], int &num){ cout << "Enter number of temperatures to input: "; cin >> num; while(num < 1 || num > 30){ cout << "Number of temperatures must be in range 1 and 30(inclusive)." << endl; cout << "Enter number of temperatures to input: "; cin >> num; } for(int i = 0; i < num; i++){ cout << "Enter temperature in Fahrenheit: "; cin >> fTemp[i]; while(fTemp[i] < -175.0 || fTemp[i] > 175.0){ cout << "Temperature must be between -175.0 to 175.0(inclusive)." << endl; cout << "Enter temperature in Fahrenheit: "; cin >> fTemp[i]; } cTemp[i] = fahrenheitToCelsius(fTemp[i]); } } //Function to sort temperatures using bubble sort void sortTemp(double temp[], const int num){ for(int i = 0; i < num - 1; i++) for(int j = 0; j < num - i - 1; j++) if(temp[j] > temp[j + 1]){ //Swap adjacent temperatures double t = temp[j]; temp[j] = temp[j + 1]; temp[j + 1] = t; } } //Function to get average temperature double getAvgTemp(const double temp[], const int num){ double sum = 0.0; for(int i = 0; i < num; i++) sum += temp[i]; return sum/num; } //Function to get highest temperature double getHighTemp(const double temp[], const int num){ double high = temp[0]; for(int i = 1; i < num; i++) if(temp[i] > high) high = temp[i]; return high; } //Function to get lowest temperature double getLowTemp(const double temp[], const int num){ double low = temp[0]; for(int i = 1; i < num; i++) if(temp[i] < low) low = temp[i]; return low; } //Function to get number of temperatures above average int numAboveAverage(const double temp[], const int num){ double avg = getAvgTemp(temp, num); int n = 0; for(int i = 0; i < num; i++) if(temp[i] > avg) n++; return n; } //Function to get number of temperatures equal to average int numEqualToAverage(const double temp[], const int num){ double avg = getAvgTemp(temp, num); int n = 0; for(int i = 0; i < num; i++) if(temp[i] == avg) n++; return n; } //Function to get number of temperatures below average int numBelowAverage(const double temp[], const int num){ double avg = getAvgTemp(temp, num); int n = 0; for(int i = 0; i < num; i++) if(temp[i] < avg) n++; return n; } //Function to get number of Fahrenheit temperatures 100 or higher int numFHigherThan100(const double temp[], const int num){ int n = 0; for(int i = 0; i < num; i++) if(temp[i] >= 100) n++; return n; } //Function to get number of Fahrenheit temperatures > 32 but < 100 int numFBetween32And100(const double temp[], const int num){ int n = 0; for(int i = 0; i < num; i++) if(temp[i] > 32 && temp[i] < 100) n++; return n; } //Function to get number of Fahrenheit temperatures 32 or lower int numFLowerThan32(const double temp[], const int num){ int n = 0; for(int i = 0; i < num; i++) if(temp[i] <= 32) n++; return n; } void printReport(const double fTemp[], const double cTemp[], const int num){ //Part (a) cout << "\nTemperatures in ascending order:" << endl; cout << left << setw(15) << "Fahrenheit" << setw(15) << "Celsius" << endl; for(int i = 0; i < num; i++) cout << left << setprecision(1) << fixed << setw(15) << fTemp[i] << setw(15) << cTemp[i] << endl; cout << endl; //Part (b) cout << "Average temperature(in Fahrenheit): " << getAvgTemp(fTemp, num) << endl; cout << "Average temperature(in Celsius): " << getAvgTemp(cTemp, num) << endl; cout << endl; //Part (c) cout << "Highest temperature(in Fahrenheit): " << getHighTemp(fTemp, num) << endl; cout << "Lowest temperature(in Fahrenheit): " << getLowTemp(fTemp, num) << endl; cout << "Highest temperature(in Celsius): " << getHighTemp(cTemp, num) << endl; cout << "Lowest temperature(in Celsius): " << getLowTemp(cTemp, num) << endl; cout << endl; //Part (d) cout << "Number of temperature inputs: " << num << endl; cout << endl; //Part (e) cout << "Number of temperatures above average(in Fahrenheit): " << numAboveAverage(fTemp, num) << endl; cout << "Number of temperatures equal to average(in Fahrenheit): " << numEqualToAverage(fTemp, num) << endl; cout << "Number of temperatures below average(in Fahrenheit): " << numBelowAverage(fTemp, num) << endl; cout << "Number of temperatures above average(in Celsius): " << numAboveAverage(cTemp, num) << endl; cout << "Number of temperatures equal to average(in Celsius): " << numEqualToAverage(cTemp, num) << endl; cout << "Number of temperatures below average(in Celsius): " << numBelowAverage(cTemp, num) << endl; cout << endl; //Part (f) cout << "Number of temperatures 100 or higher(in Fahrenheit): " << numFHigherThan100(fTemp, num) << endl; cout << "Number of temperatures greater than 32 but less than 100(in Fahrenheit): " << numFBetween32And100(fTemp, num) << endl; cout << "Number of temperatures 32 or lower(in Fahrenheit): " << numFLowerThan32(fTemp, num) << endl; cout << endl; } int main(){ const int MAX = 30; int num = 0;//Number of temperatures double fTemp[MAX], cTemp[MAX];//Array to hold Fahrenheit and Celsius temperatures inputTemp(fTemp, cTemp, num); sortTemp(fTemp, num); sortTemp(cTemp, num); printReport(fTemp, cTemp, num); return 0; }
SAMPLE OUTPUT:
FOR ANY HELP JUST DROP A COMMENT
You can vary it as long as the fahr and cels temperatures line up vertically and everything is clearly labeled. This program involves inputting a set of Fahrenheit temperatures and performing a set...
General overview This program will convert a set of temperatures from Fahrenheit to Celsius and Kelvin. Your program will be reading in three double values. The first values are starting and ending temperatures. The third value is the increment value. There is no prompt for the input. There is an error message that can be displayed. This is discussed later. You need to display output for all of the values between the starting and ending values. First two values are...
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...
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...
Write a C++ program that prompts a user to enter a temperature in Fahrenheit as a real number. After the temperature is entered display the temperature in Celsius. Your program will then prompt the user if they want to continue. If the character n or N is entered the program will stop; otherwise, the program will continue. After your program stops accepting temperatures display the average of all the temperatures entered in both Fahrenheit and Celsius. Be sure to use...
Write a program in C++ that gives the temperature of earth at a depth. It must be in C++ and follow the information below: Problem description Write a program to take a depth in kilometers inside the earth as input data; calculate and display the temperature at this depth in both degrees Celsius and degree Fahrenheit. The formulas are: Celsius temperature at depth in km: celsius = 10 x depth(km) + 20 Convert celsius to fahrenheit: fahrenheit = 1.8 x...
You must write a C program that prompts the user for two numbers (no command line input) and multiplies them together using “a la russe” multiplication. The program must display your banner logo as part of a prompt to the user. The valid range of values is 0 to 6000. You may assume that the user will always enter numerical decimal format values. Your program should check this numerical range (including checking for negative numbers) and reprompt the user for...
C++ optional exercise. You are going to convert temperatures in this program. You will give the user the choice of converting Fahrenheit to Celsius or Celsius to Fahrenheit. With the correct answer you will also display the number entered. The user should have the option to convert as many temperatures as they want. Use functions and a menu (also a function) and, assume they will convert at least one temperature. When finished upload and submit the zipped project. the formulas...
This program will take the user's input as a temperature in degrees Fahrenheit. The user will then click a radio button indicating whether a table of temperatures, starting with the entered value, will be displayed in increments of 5 degrees F or 10 degrees F. When a submit button is clicked your code will display a HTML table of temperature values. The first column will be temperatures in degrees Fahrenheit, given in increments of 5 or 10 degrees F, depending...
C++ requirements All values must be read in as type double and all calculations need to be done using type double. For part 2 you MUST have at least 4 functions, including main. The main function will be the driver of the program. It needs to either do the processing or delegate the work to other functions. Failure to follow the C++ requirements could reduce the points received from passing the tests. General overview This program will convert a set...
CIST 1305 – Program Design and Development Chapter 4 Assignment #7 [Decisions/If Statements & Loops] (50 Points) Please do the following exercises: Pastoral College is a small college in the Midwest. Design the pseudo-code for a program that accepts a student name, major field of study, and grade point average. Display a student’s data with the message “Dean’s list” if the student’s grade point average is above 3.5, “Academic probation” if the grade point average is below 2.0, and no...