Question

In: Computer Science

An amateur meteorologist keeps a list of daily temperatures and wants a program to calculate how...

An amateur meteorologist keeps a list of daily temperatures and wants a program to calculate how many times the maximum temperature occurred. For example, if the list of temperatures is [21, 24, 24, 23, 20, 19, 21, 24], the maximum of 24 occurs 3 times.

  • a.Consider the problem of calculating how many times the maximum temperature occurs.

    • i.What are the admissible inputs of the problem?
    • ii.What is the output of this problem?

  • b.Write three tests for this problem. The inputs should be different from the example given in the scenario description above. At least one of your tests must be a borderline case. Present the tests in a table, with a column for each input and output, and an extra column with a brief explanation of why you selected each test, as is done for example in Block 2 Part 2 Activity 2.10.

  • c.Decompose the problem into sub-problems. Use the > notation and state in brackets the type of the problem and of each sub-problem, following the example in Block 2 Part 2 Activity 2.44.

  • Choose the patterns for the subproblem types you identified, instantiate the patterns into an algorithm, and translate the algorithm into code.'

Solutions

Expert Solution

Answer for Part (a)

In this problem, we are trying to find the occurrence of maximum temperature (which is 24 & occurs 3 times)

The inputs in the program is the array of temperature list i.e. [t1, t2, t3.........., tn] where the size of the array will be n.

Therefore, first admissible input will be n which is the number of temperatures user wants. And based on that, we can ask user to input t1, t2 t3 upto tn

The output will be the largest element of the array with its frequency of occurrence.

Inputs (2 inputs) Number of temperatures , say n -> must be an integer (1 or more)
[t1, t2, t3, t4.......tn] -> Positive Integers, Negative Integers, Floating point numbers (decimal numbers).
Outputs (2 outputs) Max temp (Largest no. of array)
No.of occurrences of largest no. in array

Answer for Part (b)

  • Test cases
Inputs Outputs Brief Explanation
6 inputs -> [31.5 , 32.5 , 33.6, 34.8, 35.5 , 35.8]

35.8 (max temp)

1 (single occurrence)

This test case is to show that if the temperatures are in decimals
8 inputs -> [-1,-2,-8, -7, -6, -4, -1, -5]

-1 (max temp)

2 occurrences

This test case is to show that if all the temperature is in negative, then least negative is the maximum temperature
12 inputs -> [-1, -2, -3, 3, 2 , 0, -3, 2, 5, 4 , 5, 3]

5 (max temp)

2 occurrences

This test case contains positive as well as negative temperatures

Related Solutions

An amateur meteorologist wants to keep track of weather conditions during the past year's three -month...
An amateur meteorologist wants to keep track of weather conditions during the past year's three -month summer season and has designated each day as either rainy ('R'), cloudy ('C'), or sunny ('S'). Write a modu lar program that stores this information in a 3 x 30 array of characters, where the row indicates the month (0 = June, 1 = July, 2 = August) and the column indicates the day of the month. Note that data is not being collected...
Grocery List Program Write a program that keeps track of the user's grocery list items. Prompt...
Grocery List Program Write a program that keeps track of the user's grocery list items. Prompt the user if they'd like to (each action is a function): See the list Display all items (if any) in the list Add item to their list Confirm with the user before adding item (y/n or yes/no) If they enter a duplicate item, notify them the item already exists Remove items from their list Confirm with the user before removing item (y/n or yes/no)...
Write a C++ program that takes in a set of daily average temperatures (up to a...
Write a C++ program that takes in a set of daily average temperatures (up to a maximum of 30): 1.Ask the user for a temperature 2.If the user enters a -1 then stop asking for temperatures. 3. After the user is done entering temperatures: a. Print out the temperatures entered. b. print out the average, high and low temperatures. To get average, use: average = (sum of temps) divided by (count of temps) to get max or min, either keep...
I am trying to add two linked-list based integers, but the program keeps giving me the...
I am trying to add two linked-list based integers, but the program keeps giving me the incorrect result. I am trying to add (List 1: 43135) + (List 2: 172). I have pasted the code below #include <iostream> using namespace std; //Linked list node class Node {    public:    int num;    Node* next; }; //Function to create a new node with given numbers Node *new_Node(int num) {    Node *newNode = new Node();    newNode->num = num;   ...
(Write a program in C++) A local instructor wants you to write a program to calculate...
(Write a program in C++) A local instructor wants you to write a program to calculate the average score made on exams by her students. For simplicity, she always has only 12 students in each course she teaches. She teaches multiple subjects so she would like to enter the name of the exam. She wants the program to also determine the highest and lowest scores and the number of students who passed and failed the exam. A score of 60...
A company wants a program that will calculate the basic pay information for all of their...
A company wants a program that will calculate the basic pay information for all of their employees. The following requirements are necessary to make the program work as it needs to: This program must allow the user to input whether he or she is hourly or salaried. If salaried, the employee should be prompted to enter a weekly salary. If hourly, the employee should be prompted to enter an hourly wage and the number of hours worked, so that the...
Write C++ a program that shows a class called gamma that keeps track of how many...
Write C++ a program that shows a class called gamma that keeps track of how many objects of itself there are. Each gamma object has its own identification called ID. The ID number is set equal to total of current gamma objects when an object is created. Test you class by using the main function below. int main()    {    gamma g1;    gamma::showtotal();    gamma g2, g3;    gamma::showtotal();    g1.showid();    g2.showid();    g3.showid();    cout <<...
C++ program: ABC Co wants you to develop a C++ program to calculate the total invoice...
C++ program: ABC Co wants you to develop a C++ program to calculate the total invoice based on the user inputs item price and the quantity of the item purchased, taking into consideration the discount given for each category as follow: Less than 10 Item: No discount Between 10 and 20 items: 10 % off the item price More than 20 items: 20% off the item price. Your Program should display, the total before discount, how much discount and the...
A local instructor wants you to write a c++ program using arrays to calculate the average...
A local instructor wants you to write a c++ program using arrays to calculate the average score made on exams by her students. For simplicity, she always has only 12 students in each course she teaches. She teaches multiple subjects so she would like to enter the name of the exam. She wants the program to also determine the highest and lowest scores and the number of students who passed and failed the exam. A score of 60 or above...
I need this program in  Paython programing language wants to maintain a list of quiz Questions, refer...
I need this program in  Paython programing language wants to maintain a list of quiz Questions, refer to as their Question Pool, in an external data file. Each Question should have the question text, point value, four answer choices, and the correct answer stored. Since they want to keep it fun, each question should also store witty retorts given as Feedback text to the user along with the answer. The application should have a Graphical User Interface (GUI), which allows the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT