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
MrRa [10]
3 years ago
9

Write a RainFall class that stores the total rainfall for each of 12 months into an array of doubles. The program should have me

thods that return the following: the total rainfall for the year the average monthly rainfall the month with the most rain the month with the least rain Demonstrate the class in a complete program and use java 8 examples to do so. Input Validation: Do not accept negative numbers for monthly rainfall figures.
Computers and Technology
1 answer:
Yakvenalex [24]3 years ago
6 0

Answer:

Explanation:

The following code is written in Java. It creates the Rainfall class with two constructors, one that passes the entire array of rainfall and another that initializes an array with 0.0 for all the months. Then the class contains a method to add rain to a specific month, as well as the three methods requested in the question. The method to add rain validates to make sure that no negative value was added. 8 Test cases were provided, and any methods can be called on any of the 8 objects.

class Brainly {

   public static void main(String[] args) {

       Rainfall rain1 = new Rainfall();

       Rainfall rain2 = new Rainfall();

       Rainfall rain3 = new Rainfall();

       Rainfall rain4 = new Rainfall();

       Rainfall rain5 = new Rainfall();

       Rainfall rain6 = new Rainfall();

       Rainfall rain7 = new Rainfall();

       Rainfall rain8 = new Rainfall();

   }

}

class Rainfall {

   double[] rainfall = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};

   public Rainfall(double[] rainfall) {

       this.rainfall = rainfall;

   }

   public Rainfall() {

   }

   public void addMonthRain(double rain, int month) {

       if (rain > 0) {

           rainfall[month-1] = rain;

       }

   }

   public double totalRainfall() {

       double total = 0;

       for (double rain: rainfall) {

           total += rain;

       }

       return total;

   }

   public double averageRainfall() {

       double average = totalRainfall() / 12;

       return average;

   }

   public double rainiestMonth() {

       double max = 0;

       for (double rain : rainfall) {

           if (rain > max) {

               max = rain;

           }

       }

       return max;

   }

}

You might be interested in
How do you change the top and bottom margins of an entire document
Elodia [21]
Deep depending on the document editor, you should be able to just click either the top or bottom margin to edit!
6 0
4 years ago
4. What is the difference between portrait orientation and landscape orientation? (1.0 points)
Bezzdna [24]

Answer:

Portrait orientation is taller then it is wide, while landscape orientation is wider then it is tall.

Explanation:

3 0
4 years ago
Write an INSERT statement that adds this row to the Categories table: category_name: Brass Code the INSERT statement so MySQL au
nexus9112 [7]

Answer:

Query:

insert into Categories (category_name) values ('Brass Code');

Explanation:

  • The query is a medium through which a user of the database can communicate with the database or tables or any particular data. It means that when a user wants to access the database or tables or any data then there is a medium of query which is also known as SQL query.
  • The query can help to make the database(which is a collection of tables), make the table in the database, add the data, modify the data or delete the data.
  • For add the data there is a insert query which syntax is as follows: insert into table_name (column_1_name,column_2_name,....,column_n_name) values (column_1_values,column_2_values,....,column_n_values);
  • There is only one column value in the question which a user needs to add so that can be done by the help of a statement that is defined on the answer part.
5 0
4 years ago
What are the Technical Skills do Penetration Testers need to have?
Alla [95]

1. Tester should understand the vulnerability of the system because by this skill it should be able to secure the system for the parts where the attacks can be done.

2. Understand the web technologies and communication techniques of them because the two way communication understanding is one of the most important skill a tester should have so that he/she should have a proper image of what the system doing and how it is doing it.

3. Ability yo code scripts and most importantly understand them because while testing there are many script code to be read and understand for any bug or error the system is facing.

5 0
3 years ago
Write a program to compute an employee's weekly pay and produce a pay slip showing name, gross, pay, deductions, and net pay. Th
Umnica [9.8K]

Answer:

# get the employee data

family_name = input("Enter family name: ")

given_name = input("Enter given name: ")

hourly_rate = int(input("Enter hourly rate of pay: "))

hours = int(input("Enter hours worked for the week: "))

tax_cat = input("Enter tax category from a through e: ")

is_charit = input("Do you want to donate $20 to charity y/n: ")

gross_pay = 0

net_pay = 0

deductions = ""

# gross_pay

if hours > 40:

   gross_pay = hours * (2 * hourly_rate)

else:  

   gross_pay = hours * hourly_rate

# net_pay and deduction

if tax_cat == 'a':

   if is_charit == 'y':

       net_pay = gross_pay - 20

       deduction = "$20 charity donation"

   else:

       net_pay = gross_pay

       deduction = "0% tax"

elif tax_cat == 'b':

   if is_charit == 'y':

       net_pay = gross_pay - ( 0.1 * gross_pay) - 20

       deduction = "$20 charity donation and 10% tax"

   else:

       net_pay = gross_pay - (0.1 * gross_pay)

       deduction = "10% tax"

elif tax_cat == 'c':

   if is_charit == 'y':

       net_pay = gross_pay - ( 0.2 * gross_pay) - 20

       deduction = "$20 charity donation and 20% tax"

   else:

       net_pay = gross_pay - (0.2 * gross_pay)

       deduction = "20% tax"

elif tax_cat == 'd':

   if is_charit == 'y':

       net_pay = gross_pay - ( 0.29 * gross_pay) - 20

       deduction = "$20 charity donation and 29% tax"

   else:

       net_pay = gross_pay - (0.29 * gross_pay)

       deduction = "29% tax"

if tax_cat == 'e':

   if is_charit == 'y':

       net_pay = gross_pay - ( 0.35 * gross_pay) - 20

       deduction = "$20 charity donation and 35% tax"

   else:

       net_pay = gross_pay - (0.35 * gross_pay)

       deduction = "35% tax"

# output of the employee's weekly pay.

print(f"Employee name: {given_name} {family_name}")

print(f"Gross pay: ${gross_pay}")

print(f"Net pay: {net_pay}")

print(f"Deductions: {deduction}")

Explanation:

The python program uses the input built-in function to prompt and get user data for the program. The gross pay returns the total pay of the employee without any deduction while net pay returns the pay with all deductions included.

6 0
3 years ago
Other questions:
  • Digital art is created by using
    6·1 answer
  • Using the ____ browsing mode offered by some browsers can prevent personal information from being left on a public computer.
    9·1 answer
  • Universal Containers has a requirement to integrate Salesforce with an external system to control record access. What option sho
    11·1 answer
  • All of the following are aspects of the search process except
    8·1 answer
  • Write a program that takes in an integer in the range 20-98 as input. The output is a countdown starting from the integer, and s
    12·1 answer
  • Expresa tu reflexión sobre la necesidad de un código de etica para la IA (inteligencia artificial) , oponia sobre los bots en la
    15·1 answer
  • Guyssss......urgent helppp plsss answerrrr
    5·1 answer
  • Time management is the ability to use time effectively.
    13·2 answers
  • Universal containers wants internal support requests to be directed to any of the IT reps. They want external support requests t
    9·1 answer
  • The ____ project was developed to make information widely available in an attempt to thwart internet and network hackers.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!