1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Ksju [112]
3 years ago
10

Write a program that calculates the average rainfall for three months. The program should ask the user to enter the name of each

month, such as June or July, and the amount of rain (in inches) that fell each month. The program should display a message similar to the following: The average rainfall for June, July, and August is 6.72 inches.
Computers and Technology
1 answer:
sergeinik [125]3 years ago
4 0

Answer:

// program in C++.

#include <bits/stdc++.h>

using namespace std;

// main function

int main()

{

   // string array

   string m[3];

   // array to store rainfall

   double rainfall[3];

   // variables

   double avg_rainfall,sum=0;

   

   for(int i=0;i<3;i++)

   {

       cout<<"Enter name of month "<<i+1<<" :";

       // read month name

       cin>>m[i];

       cout<<"Enter rainfall (inches)  in month "<<i+1<<" :";

       // read rainfall

       cin>>rainfall[i];

       // sum of rainfall

       sum+=rainfall[i];

   }

   // Average rainfall

   avg_rainfall=sum/3;

   // print Average rainfall

   cout<<"Average rainfall for "<<m[0]<<","<<m[1]<<","<<m[2]<<" is "<<avg_rainfall<<" inches."<<endl;

return 0;

}

Explanation:

Create string array "m" to store name of month and double array "rainfall" to store rainfall. Read name of 3 months and rainfall in that month.Find the sum of all the rainfall  and the average rainfall.Print the average rainfall of 3 months.

Output:

Enter rainfall (inches)  in month 2 :45                                                                                    

Enter name of month 3 :july                                                                                                

Enter rainfall (inches)  in month 3 :43                                                                                    

Average rainfall for may,june,july is 42.6667 inches.

You might be interested in
Write the code to compute and output how many times the value 99 is found in an array of integers named numbers
astraxan [27]
Thank you for being the rare question where you actually provide what language you want your answer in; I approve, and encourage this.

In Java, the following will work.
I made it a bit more versatile to work with others numbers, other than 99, if you so please (if not, just hardcode the 99 in yourself).

// Example list - fill this with numbers yourself.
ArrayList<Integer> nums = new ArrayList<>();
int n = 99;
int count = (int)nums.stream().filter(i -> i == n).count();
System.out.println(n + " occurences.");
8 0
3 years ago
What is the best description of a programming language?
sergejj [24]

Answer: A: A language that directs a computer to perform tasks and carry out

functions

Explanation: I'm a programmer, and coder, this is the best answer from the given choices

4 0
2 years ago
What is that black thing on my wall?
Darya [45]
I'm guessing your television if it's a flat screen
7 0
2 years ago
How do you add a simple header that will appear in a single column on the left of a document
malfutka [58]

When adding a header, you need to double tap the top of the document.

4 0
2 years ago
Read 2 more answers
Write a function named dice_eval that accepts two parameters representing numeric dice values and returns a string describing th
Zigmanuir [339]

Following are the "dice_eval" method code into python language.

Program Explanation:

  • Defining a method "dice_eval" that takes two variables "d1,d2" in its parametes.
  • Inside the method, multiple conditional statements were used that adds the parameter values and calculates its value which can be defined as follows:
  • In the if block, it adds the parameters and uses or gate that check its value that is equal to 7 or 11. so, it will return a string message that is 'Winner!'.  
  • In the elif block, it adds the parameters and uses or gate that check its value that is equal to 2 or 3 or 12. so, it will return a string message that is ' C r aps ! '.
  • In the else block, it uses a return keyword that adds parameter value and prints a string value.
  • Outside the method "d1,d2" is declared that inputs the value from the user-end, and passes the value into the method, and prints its value.

Program:

def dice_eval(d1, d2):#defining a method dice_eval that takes two parameters

if (d1+d2)==7 or (d1+d2)==11:#defining if block that adds parameter value and use or operator to check its value

return 'Winner!'#return string value

elif (d1+d2)==2 or (d1+d2)==3 or (d1+d2)==12:#defining elif block that adds parameter value and use or operator to check its value

return 'C r aps!'#return string value

else:#defining else block

return 'Point is '+str(d1+d2)#return string value with adding parameter

d1=int(input())#defining d1 that input value

d2=int(input())#defining d2 that input value

print(dice_eval(d1,d2))#calling method and print its return value

Output:

Please find the attached file

Please find the complete code in the attached file.

Learn more:

brainly.com/question/15011927

4 0
2 years ago
Other questions:
  • There is a colony of 8 cells arranged in a straight line where each day every cell competes with its adjacent cells(neighbour).
    11·1 answer
  • This assignment is to read from an input file and process the data for a group of people. Your program calculates the interest a
    5·1 answer
  • How does microchip work
    12·1 answer
  • Alpha Technologies, a newly established company, wants to share information about its work with people all over the world. Which
    9·1 answer
  • Jeremy wishes to create a site map for his website. What tag will surround the URL of his home page? A. B. C. D.
    8·1 answer
  • Blank spaces or unseen control characters in a data file are referred to as
    5·2 answers
  • When can you access the BIOS setup utility?
    14·1 answer
  • 15 points. Please give an actual answer and not some random thing. this is not just free points. Correct answer will receive bra
    12·2 answers
  • Driswers.
    13·2 answers
  • Colorful bead bracelet in codehs
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!