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
Alex73 [517]
3 years ago
6

Write the definition of a function max that has three int parameters and returns the largest.

Computers and Technology
2 answers:
dezoksy [38]3 years ago
7 0

Answer:

int max(int x, int y, int z){

if(x > y && x > z)

return x;

else if(y > x && y > z)

return y;

else

return z;

}

Explanation:

I am going to write a c function for this.

The arguments are the values, and it is a int function because it returns an integer. So

The if clause is used to verify the largest value.

int max(int x, int y, int z){

if(x > y && x > z)

return x;

else if(y > x && y > z)

return y;

else

return z;

}

g100num [7]3 years ago
4 0

Solution:

The definition of a function max that has three int parameters and returns the largest is given bellow:

def max(x,y,z):

if (x>z and x>y):

return (x)

elif (y>x and y>z):

return y

else:

return z

Thus this is required right answer.

You might be interested in
Technical colleges offer certification in audio engineering through programs that are normally from 2 to 6 months long.
Murrr4er [49]

Answer:

False

Explanation:

i said so

8 0
3 years ago
Write a RainFall class that stores the total rainfall for each of 12 months into an array of doubles. The program should have me
RSB [31]

Answer:

Explanation:

The code provided worked for the most part, it had some gramatical errors in when printing out the information as well as repeated values. I fixed and reorganized the printed information so that it is well formatted. The only thing that was missing from the code was the input validation to make sure that no negative values were passed. I added this within the getMonths() method so that it repeats the question until the user inputs a valid value. The program was tested and the output can be seen in the attached image below.

import java.io.*;

import java.util.*;

class Rainfall

{

   Scanner in = new Scanner(System.in);

   private int month = 12;

   private double total = 0;

   private double average;

   private double standard_deviation;

   private double largest;

   private double smallest;

   private double months[];

   public Rainfall()

   {

       months = new double[12];

   }

   public void setMonths()

   {

       for(int n=1; n <= month; n++)

       {

           int answer = 0;

           while (true) {

               System.out.println("Enter the rainfall (in inches) for month #" + n + ":" );

               answer = in.nextInt();

               if (answer > 0) {

                   months[n-1] = answer;

                   break;

               }

           }

       }

   }

   public void getTotal()

   {

       total = 0;

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

       {

           total = total + months[i];

       }

       System.out.println("The total rainfall for the year is " + total);

   }

   public void getAverage()

   {

       average = total/12;

       System.out.println("The average monthly rainfall is " + average);

   }

   public void getLargest()

   {

       double largest = 0;

       int largeind = 0;

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

       {

           if (months[i] > largest)

           {

               largest = months[i];

               largeind = i;

           }

       }

       System.out.println("The largest amount of rainfall was " + largest +

               " inches in month " + (largeind + 1));

   }

   public void getSmallest()

   {

       double smallest = Double.MAX_VALUE;

       int smallind = 0;

       for(int n = 0; n < month; n++)

       {

           if (months[n] < smallest)

           {

               smallest = months[n];

               smallind = n;

           }

       }

       System.out.println("The smallest amount of rainfall was " + smallest +

               " inches in month " + (smallind + 1));

   }

   public static void main(String[] args)

   {

       Rainfall r = new Rainfall();

       r.setMonths();

       r.getTotal();

       r.getSmallest();

       r.getLargest();

       r.getAverage();

   }

}

8 0
2 years ago
Which argument forces a writer to return to and change the input before resolving a “UnicodeError”?
garri49 [273]

Answer:

B

Explanation:

3 0
3 years ago
What are some ways you can use the Effect Options dialog box to customize animations in a presentation? Check all
aliina [53]
The first and the 3 ones
4 0
2 years ago
Read 2 more answers
The Subset Sum problem is a generalization of the Knapsack problem. Group of answer choices True False g
Katarina [22]

Answer: True

Explanation:

Subset sum problem and Knapsack problem can be solved using dynamic programming.

In case of Knapsack problem there is a set of weights associative with objects and a set of profits associated with each object and a total capacity of knapsack let say C. With the help of dynamic programming we try to include object's weight such that total profit is maximized without fragmenting any weight of objects and without exceeding the capacity of knapsack, it is also called as 0/1 knapsack problem.

Similar to knapsack problem, in subset sum problem there is set of items and a set of weights associated with the items and a capacity let say C, task is to choose the subset of items such that total sum of weights associated with items of subset is maximized without exceeding the total capacity.

On the basis of above statements we can say that subset sum problem is generalization of knapsack problem.

4 0
3 years ago
Other questions:
  • What do you click to create a new presentation in Normal view? A. Section B. Blank Presentation C. Layout D. New Slide
    14·2 answers
  • Write a program that asks for 'name' from the user and then asks for a number and stores the two in a dictionary (called 'the_di
    9·1 answer
  • Which button is used to open the Start menu in Windows Vista?
    14·1 answer
  • You can join tables by using a condition in the ____ clause.​
    7·1 answer
  • What is the color difference between the iMac and iMac Pro
    14·2 answers
  • Which devices typically generate computer output? monitor, printer, speaker, projector, keyboard mouse, printer, speaker, projec
    7·1 answer
  • C:/Users/Documents/resume.docx Where is the "resume" document located in this file structure?
    12·1 answer
  • Why is experience in their own factory setting
    13·1 answer
  • What are the minimum number of bits an address bus must have in a byte addressable memory system containing only 4 KiB of memory
    8·1 answer
  • Why is quantum computing potentially a better fit for weather forecasting than classical computers?.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!