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
lidiya [134]
4 years ago
13

In the main function, define five variables of type int, named: first, second, third, fourth, and total. Also in the main functi

on, define three variables of type double named: decimalOne, decimalTwo and decimalTotal Write one function named getData which asks the user for the data and puts it in first, second, third, fourth, decimalOne, and decimalTwo. (You may copy your getData from problem H1 and make additions to manage fourth, decimalOne, and decimalTwo.) Write a function named computeTotal which can take two, or three int arguments and returns an int. Write another function, also named computeTotal which takes four int arguments and returns an int. Write another function, also named computeTotal which takes two double arguments and returns a double. Write a function named printAll which takes three arguments of type int. Write a function named printAll which takes four arguments of type int. Write a function named printAll which takes five arguments of type int. Write a function named printAll which takes three arguments of type double.
Computers and Technology
1 answer:
fiasKO [112]4 years ago
8 0

Answer:

  1. import java.util.Scanner;
  2. public class num8 {
  3.    public static void main(String[] args) {
  4.    int first, second, third, fourth,total;
  5.    double decimalOne, decimalTwo, decimalTotal;
  6.    }
  7.    public static void getData(int first, int second, int third, int fourth, double decimalOne, double decimalTwo){
  8.        System.out.println("Enter the Values");
  9.        Scanner in = new Scanner(System.in);
  10.        first=in.nextInt();
  11.        second=in.nextInt();
  12.        third=in.nextInt();
  13.        fourth=in.nextInt();
  14.        decimalOne = in.nextDouble();
  15.        decimalTwo = in.nextDouble();
  16.    }
  17.    public static int computeTotal(int first, int second, int third){
  18.        return first+second+third;
  19.    }
  20.    public static int computeTotal(int first, int second, int third, int fourth){
  21.        return first+second+third+fourth;
  22.    }
  23.   public static double computeTotal(double decimalOne, double decimalTwo){
  24.        return decimalOne+decimalTwo;
  25.    }
  26.    public static void printAll( int first, int second, int third){
  27.        System.out.println("Number one, two and three are: "+first+" "+second+" "+third);
  28.    }
  29.    public static void printAll( int first, int second, int third, int fourth){
  30.        System.out.println("Number one, two and three and four are: "+first+" "+second+
  31.                " "+third+" "+fourth);
  32.    }
  33.   public static void printAll( int first, int second, int third, int fourth, int fifth){
  34.        System.out.println("Number one, two and three and four are: "+first+" "+second+
  35.                " "+third+" "+fourth+" "+fifth);
  36.    }
  37.    public static void printAll( double first, double second, double third){
  38.        System.out.println("Number one, two and three and four are: "+first+" "+second+
  39.                " "+third);
  40.    }
  41. }

Explanation:

This solution is provided in Java:

All the variable declarations are done in the main method (lines 3-6)

Eight methods as specified in the question are created (Lines 7, 17, 20, 23, 26, 29, 33 and 37).

Observe the concept of Method Overloading (i.e. methods with same name and return types but different parameter list)

You might be interested in
What is the difference between asking a question with few points and asking a question with many? New to Brainly :D
ANTONII [103]

Answer:

one would be more helpful and the other more vague and less convincing.

6 0
3 years ago
Write a program that asks the user to enter five different, integer numbers. The program then reports the largest number and the
Akimi4 [234]

Answer:

// here is code in C++.

#include <bits/stdc++.h>

using namespace std;

// main function

int main()

{

// variables

  int minn=INT_MAX;

   int maxx=INT_MIN;

   int n1,n2,n3,n4,n5;

   cout<<"enter five Numbers:";

   //read 5 Numbers

   cin>>n1>>n2>>n3>>n4>>n5;

   // find maximum

   if(n1>maxx)

    maxx=n1;

    if(n2>maxx)

    maxx=n2;

    if(n3>maxx)

    maxx=n3;

    if(n4>maxx)

    maxx=n4;

    if(n5>maxx)

    maxx=n5;

   // find minimum

   if(n1<minn)

    minn=n1;

    if(n2<minn)

    minn=n2;

    if(n3<minn)

    minn=n3;

    if(n4<minn)

    minn=n4;

    if(n5<minn)

    minn=n5;

   // print maximum and minimum

   cout<<"maximum of five numbers is: "<<maxx<<endl;

   cout<<"minimum of five numbers is: "<<minn<<endl;

return 0;

}

Explanation:

Declare two variables "minn" & "maxx" and initialize them with INT_MAX and INT_MIN respectively.Then read the five number from user and compare it with "minn" & "maxx" ,if input is greater than "maxx" then update "maxx" or if input is less than "minn" then update the "minn". After all the inputs, "minn" will have smallest and "maxx" will have largest value.

enter five Numbers:5 78 43 55 12

maximum of five numbers is: 78

minimum of five numbers is: 5

4 0
3 years ago
Open Meet and enter this code: jnw-xodp-yij only for boys​
Agata [3.3K]
Skegeuabdvsjalalsjsn
8 0
3 years ago
Read 2 more answers
The benefit of host and guest operating system difference is:
Mazyrski [523]
B bc i said sooooooooo
5 0
3 years ago
Read 2 more answers
A work order does all of the following EXCEPT:
Lady_Fox [76]

Answer:

c

Explanation:

6 0
3 years ago
Other questions:
  • Which method of encryption is based on physics principles?
    5·1 answer
  • Why are id thieves hard to catch?
    14·1 answer
  • 5. How do vector graphics used with CRT technology work? List at least one of vector graphics’ advantages over raster graphics,
    9·1 answer
  • What aspect of web design is Gloria following when she uses the same color
    5·2 answers
  • When using a file name you have to use only lower case letters<br>true or false
    11·1 answer
  • What is the shortest sequence of MIPS instructions that extracts a field for the constant values of bits 7-21 (inclusive) from r
    7·1 answer
  • Suppose there are 69 packets entering a queue at the same time. Each packet is of size 7 MiB. The link transmission rate is 1.7
    9·1 answer
  • With a DUI charge on a driver’s record ______________.
    10·1 answer
  • Three positive impacts of computer technology in our society.​
    7·2 answers
  • Assume you have written a method with the header num yourMethod(string name, num code). The method's type is ____ .
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!