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.
Alphabetical Order. The answer(s) are on quizlet btw lol.
public class ArithmeticAssignment {
public static void main(String[] args) {
Tester test = new Tester();
test.printTester();
}
}
class Tester{
Tester(){
}
void printTester(){
int i1 = 79 + 3 * (4 + 82 -68) - 7 +19;
int i2 = (179 +21 +10) / 7 + 181;
int i3 = 10389 * 56 * 11 + 2246;
System.out.println(i1);
System.out.println(i2);
System.out.println(i3);
}
}
I think this is what you wanted. I hope this helps!
Answer:
#include <iostream>
#include<time.h>
using namespace std;
class Student
{
public :
int grades[20]; //array of grades
double average(int arr[],int n) //method to calculate average of array of grades passed
{
int sum=0;
for(int i=0;i<n;i++) //loop to calculate sum of all grades
sum=sum+arr[i];
return sum/n; //average is sum of items/number of items
}
int get_grade() //method to return grade number(1-14)
{
srand(time(NULL)); //method to generate different random number each time
int num = rand() % 14 + 1; //method to generate random number b/w 1-14
return num;
}
};
int main()
{
Student s;
int grade[]={5,3,9,8,10};
cout<<"Average is : "<<s.average(grade,5);
return 0;
}
OUTPUT :
Average is : 7
Explanation:
A class Student is created in which a method named average is there to calculate average of the grades passed and a method to generate a grade number b/w 1-14.
To observe ultraviolet, x-rays, gamma-rays or infrared, astronomers have had to put telescopes outside of Earth's atmosphere, normally in orbit around the Earth.