Problem:
You will write a program to compute some statistics based on monthly average temperatures for a given month in each of the years 1901 to 2016. The data for the average August temperatures in the US has been downloaded from the Climate Change Knowledge Portal, and placed in a file named “tempAugData.txt”, available on the class website. The file contains a sequence of 116 values. The temperatures are in order, so that the first one is for 1901, the second is for 1902, and so on through 2016.
The statistics you should compute in your program are:
• The average of the monthly average temperatures for the entire time period.
• The number of years that the monthly average reached at least X degrees where X is a value input from the user. These years should also be displayed to the screen.
• The maximum monthly average temperature for the time period and in what year it occurred.
• The minimum monthly average temperature for the time period and in what year it occurred.
Input: Your program should ask the user for the name of the file, and then open that file for input. It should then ask the user for a boundary temperature (the X in the second bullet above) that is used to calculate some of the statistics. Processing: Compute the statistics requested above.
Output: Display the statistics, labeled, and with the temperatures formatted to 1 decimal place. Also output the count of the years above X before outputting the list of the years.
Sample output:
Please enter the name of the temperature data file: tempAugData.txt Please enter the boundary temperature: 68.0
Climate Data statistics: Average temperature: 66.2
Years that averaged at least 68.0 degrees: 7 1936 1995 2003 2007 2010 2011 2016
Maximum average temperature: 68.9 occurred in 2007
Minimum average temperature: 63.9 occurred in 1927
Additional Requirements:
• Your program must compile and run, otherwise you will receive a 0.
• Your program should test for file open errors.
• I recommend temporarily echoing the input from the file to the screen (using cout) to be sure you are reading the input correctly into your array.
• You should have many separate loops in your program. Do not try to compute everything in one single loop.
• For partial credit, implement some subset of the features completely. This will probably lead to a better score than implementing every feature poorly.
Thanks for the question, Here is the complete program in C++
===================================================================
// write a program to compute some statistics
#include<iostream>
#include<fstream>
#include<string>
#include<cstdlib>
#include<iomanip>
using namespace std;
int main(){
string filename;
cout<<"Please enter the name of the temperature data file: ";
getline(cin,filename);
double boundary_temp;
cout<<"Please enter the boundary temperature: ";cin>>boundary_temp;
ifstream infile(filename.c_str());
double temp[116];
int index=0;
double total_temperature=0;
double min_temp, max_temp;
int min_year; int max_year;
int count_atleast_boundary_temp=0;
if(infile.is_open()){
while(infile>>temp[index]){
total_temperature+=temp[index];
if(index==0){
min_temp=max_temp=temp[index];
}else if(temp[index]>max_temp){
max_temp=temp[index];
max_year=1901+index;
}else if(temp[index]<min_temp){
min_temp=temp[index];
min_year=1901+index;
}
if(temp[index]>=boundary_temp){
count_atleast_boundary_temp+=1;
}
index+=1;
}
infile.close();
}
else{
cout<<"Unable to read data from file: "<<filename<<endl;
exit(EXIT_FAILURE);
}
cout<<fixed<<setprecision(1)<<showpoint;
cout<<"\n\nClimate Data Statistics"<<endl;
cout<<"Average Temperature: "<<total_temperature/index<<endl;
cout<<"Years that averaged at least "<<boundary_temp<<" degrees: "<<count_atleast_boundary_temp<<" ";
for(int i=0;i<index;i++){
if(temp[i]>=boundary_temp)cout<<temp[i]<<" ";
}
cout<<endl;
cout<<"Maximum average temperature: "<<max_temp<<" occurred in "<<max_year<<""<<endl;
cout<<"Minimum average temperature: "<<min_temp<<" occurred in "<<min_year<<""<<endl;
}
===================================================================
A corporation named XYZ needs a program to calculate how much to pay their part-time and full-time
employees.
For full-time employees, the employees get paid time and a half for any hours over 40 that they work in a single
week. For example, if an employee works 45 hours, they get 5 hours of overtime, at 1.5 times their base pay. The
base should be at least RS. 120 an hour. This XYZ Corporation requires that an employee not work more than 60
hours in a week.
For part-time employees, they get paid time and a half for any hours over 30 that they work in a single week.
For example, if an employee works 33 hours, they get 3 hours of overtime, at 1.5 times their base pay. Their base
pay should not be less than RS. 110 an hour. This XYZ Corporation requires that an employee not work more
than 35 hours in a week.
To sum up:
An employee gets paid (hours worked) × (base pay) for each hour up to 30 or 40 hours depending upon
employee type.
For every hour over 30 or 40 depending upon employee type, they get overtime = Overtime hours × (base
pay) × 1.5.
The base pay must not be less than the minimum wage (RS. 110 or RS. 120 an hour depending upon
employee type).
The working hours must not exceed 35 or 60 depending upon employee type.
Write a program that ask user to enter Employee Name, Employee type (full-time/pat-time), working hours and
base pay. You need to write the following methods:
1. Write a method that validates the input that if it is in given range or not.
public static boolean isValidInput(Char empType, int workingHours, double
basePay)
2. A method that calculate pay based on given parameters.
public static double calculatePay(Char empType, int workingHours, double
basePay)
3. A method to calculate overtime pay. This method should be called from calculatePay if and when
required.
public static double calculateOverTimePay(int OverTimeHours, double
basePay)
CS-DS-Mathematics Program CS-123 GIFT University Gujranwala
Page 3 of 4
4. A method to display information
public static void displayInfo(String empName, int workingHours, double
totalPay)
CS-DS-Mathematics Program CS-123 GIFT University Gujranwala
Page 4 of 4
Program Name: MyArrayMethods.java [15 Points]
You are provided with the following table which contains the average high temperature data of Gujranwala for
each month of the year 2018.
Month 1 2 3 4 5 6 7 8 9 10 11 12
Average
Temperature
19.1 22.01 27.4 33.7 39.0 40.8 36.1 34.6 35.0 33.0 27.0 21.2
a. Write a method called averageTemperature that accepts an array of type double as
argument; calculates and returns the average temperature. You may use the following method
header:
public static double averageTemperature(double[] temperatures)
b. Write a method called maximumTemperature that accepts an array of type double as argument
and returns the index of maximum temperature from the array.
public static int maximumTemperature(double[] temperatures)
c. Write a method called minimumTemperature
Problem: You will write a program to compute some statistics based on monthly average temperatures for...
Problem: You will write a program a C++ to compute some statistics based on monthly average temperatures for a given month in each of the years 1901 to 2016. The data for the average August temperatures in the US has been downloaded from the Climate Change Knowledge Portal, and placed in a file named “tempAugData.txt”, available on the class website. The file contains a sequence of 116 values. The temperatures are in order, so that the first one is for...
Problem: A local amateur meteorologist has been recording daily high temperatures throughout the month of June. He would like you to write a program to compute some statistics based on the data he has collected. He has placed each daily high temperature on a separate line in a file named “summer_temps.txt”. The high temperatures are in order so that the first one is for June 1, the second is for June 2, and so on. The statistics that the meteorologist...
For this assignment, you are to write a program that does the following: read temperatures from a file name data.txt into an array, and after reading all the temperatures, output the following to the monitor: the average temperature, the minimum temperature, and the total number of temperatures read. In addition, the program must use the following functions: //precondition: fileName is name of the file to open, inFile is the input file //postcondition: inFile is opened. If inFile cannot...
Write a C program to compute average grades for a course. The course records are in a single file and are organized according to the following format: Each line contains a student’s first name, then one space, then the student’s last name, then one space, then some number of quiz scores that, if they exist, are separated by one space. Each student will have zero to ten scores, and each score is an integer not greater than 100. Your program...
INTRODUCTION You are working on development of a new power plant for Centerville, USA. Average monthly temperature data has been collected as part of designing the new power plant, and you are required to develop a computer program that will perform averaging analysis. The input data file is called temp. As you examine the input file, you notice that the first record line is the name of the city and type of data, the second record line contains the control...
write a programming code for the following problem using
Visual Basic Studio VB.
Write a program that will allow the user to enter series of mumbers and will give some useful statistics about the mambers Enter Numbers Button Click-Allow the user to enter series of nambers using imput dialog boxes. Use a loop and add the numbers to the listBox as they are input.. Prompt the user to enter"x" to stop addang numbers. Compute Statistics Button Click-Compute the following statistics...
Develop a Java program that will store data in the form of daily average temperatures for one week. Store the day and average temperature in two different arraylists. Your program should prompt the user for the day of the week (Monday through Sunday) and display both the day and temperature for each day. If “week” is entered, the output for your program should provide the temperature for each day and the weekly average. Use the looping and decision constructs in...
python
Write a program that displays a table of Celsius temperatures and equivalent Fahrenheit temperatures. You can find the formula online if necessary. Your program should print both scales accurate to one decimal place in columns 8 characters wide (see page 71). Use Celsius temperatures ranging from -40C to 40C in 10 degree increments. See Required Output. Required Output CEL FAH === -40.0 -40.0 -30.0 -22.0 -20.0 -4.0 - 10.0 14.0 0.0 32.0 10.0 50.0 20.0 68.0 30.0 86.0 40.0...
C++ Weight Statistics Write a program that monitors monthly weight loss each of 12 months into an array of doubles. The program should calculate and display the total weight loss for the year, the average monthly weight loss, and the months with the highest and lowest amounts. Input Validation: Do not accept negative numbers for monthly weight loss. Write your code here: Use the Snipping Tool to show output
Write a MARIE program to calculate some basic statistics on a list of positive numbers. The program will ask users to input the numbers one by one. Assume that all numbers will be in the range 1 to 1000. To terminate the data entry, user will input any negative number. Once the data entry is complete, the program will show four statistics about the list of numbers: (1) Count (2) Minimum value (3) Sum of numbers (4) "Mean/Average" calculation. As...