answer.
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
Virty [35]
2 years ago
9

Given 4 integers, output their product and their average, using integer arithmetic.

Computers and Technology
1 answer:
solmaris [256]2 years ago
8 0

Answer:

see explaination

Explanation:

Part 1:

import java.util.Scanner;

public class LabProgram {

public static void main(String[] args) {

Scanner scnr = new Scanner(System.in);

int num1;

int num2;

int num3;

int num4;

int avg=0, pro=1;

num1 = scnr.nextInt();

num2 = scnr.nextInt();

num3 = scnr.nextInt();

num4 = scnr.nextInt();

avg = (num1+num2+num3+num4)/4;

pro = num1*num2*num3*num4;

System.out.println(pro+" "+avg);

}

}

------------------------------------------------------------------

Part 2:

import java.util.Scanner;

public class LabProgram {

public static void main(String[] args) {

Scanner scnr = new Scanner(System.in);

int num1;

int num2;

int num3;

int num4;

double avg=0, pro=1; //using double to store floating point numbers.

num1 = scnr.nextInt();

num2 = scnr.nextInt();

num3 = scnr.nextInt();

num4 = scnr.nextInt();

avg = (num1+num2+num3+num4)/4.0; //if avg is declared as a float, then use 4.0f

pro = num1*num2*num3*num4;

System.out.println((int)pro+" "+(int)avg); //using type conversion only integer part

System.out.printf("%.3f %.3f\n",pro,avg);// \n is for newline

}

}

You might be interested in
A ______________ deals with the potential for weaknesses within the existing infrastructure to be exploited.
algol [13]

Answer:

Threat assessment

Explanation:

A threat assessment deals with the potential for weaknesses within the existing infrastructure to be exploited.

Threat Assessment is further explained as the practice of determining or ascertaining the credibility and seriousness of a potential threat, and also the probability or chases of the threat will becoming a reality.

Threat assessment is separate to the more established procedure of violence-risk assessment, which seek to forcast an individual's general capacity and tendency to respond to situations violently. Instead, threat assessment aims to interrupt people on a route to commit "predatory or instrumental violence, the type of behavior connected with targeted attacks".

3 0
2 years ago
Read 2 more answers
Choose the correct sequence for classifier building from the following.
Alekssandra [29.7K]

Answer:

b

Explanation:

First, we need to initialize the classifier.

Then, we are required to train the classifier.

The next step is to predict the target.

And finally, we need to evaluate the classifier model.

You will find different algorithms for solving the classification problem. Some of them are like  decision tree classification  etc.

However, you need to know how these classifier works.  And its explained before:

You need  to initialize the classifier at first.

All kinds of classifiers in the scikit-learn make use of the method fit(x,y) for fitting the model or the training for the given training set in level y.

The predict(x) returns the y which is the predicted label.And this is prediction.

For evaluating the classifier model- the score(x,y) gives back the certain score for a mentioned test data x as well as the test label y.

8 0
2 years ago
Given positive integer n, write a for loop that outputs the even numbers from n down to 0. If n is odd, start with the next lowe
seropon [69]

Answer:

The program in Python is as follows:

n = int(input("Enter an integer: "))

if n < 0:

   n = 0

print("Sequence:",end=" ")

for i in range(n,-1,-1):

   if i%2 == 0:

       print(i,end = " ")

Explanation:

This gets input for n

n = int(input("Enter an integer: "))

This sets n to 0 if n is negative

<em>if n < 0:</em>

<em>    n = 0</em>

This prints the string "Sequence"

print("Sequence:",end=" ")

This iterates from n to 0

for i in range(n,-1,-1):

This check if current iteration value is even

   if i%2 == 0:

If yes, the number is printed

       print(i,end = " ")

7 0
1 year ago
Pick the correct statements regarding cell references.
shusha [124]

Statement two and three is correct.

Statement 1 is incorrect. A relative reference changes when a formula is copied to another cell while Absolute references remain constant. However, it is safe to say that an absolute address can be preceded by a $ sign before both the row and the column values. It is designated by the addition of a dollar sign either before the column reference, the row reference, or both. Statement C is also correct. A mixed reference is a combination of relative and absolute reference and the formula (= A1 + $B$2) is an example of a mixed cell reference.

7 0
2 years ago
Read 2 more answers
Write a class named Employee that has private data members for an employee's name, ID_number, salary, and email_address. It shou
mario62 [17]

Solution :

class Employee:

   #Define the

   #constructor.

   def __$\text{init}$__($\text{self, nam}e$,  ID_number, $\text{salary}$, email):

       #Set the values of

       #the data members of the class.

       $\text{self.nam}e$ = name

       $\text{self.ID}$_number = ID_number

       $\text{self.salary}$ = salary

       self.email_address = email

#Define the function

#make_employee_dict().

def make_employee_dict(list_names, list_ID, list_salary, list_email):

   #Define the dictionary

   #to store the results.

   employee_dict = {}

   #Store the length

   #of the list.

   list_len = len(list_ID)

   #Run the loop to

   #traverse the list.

   for i in range(list_len):

       #Access the lists to

       #get the required details.

       name = list_names[i]

       id_num = list_ID[i]

       salary = list_salary[i]

       email = list_email[i]

       #Define the employee

       #object and store

       #it in the dictionary.

       employee_dict[id_num] = Employee(name, id_num, salary, email)

   #Return the

   #resultant dictionary.

   return employee_dict

6 0
1 year ago
Other questions:
  • Grabar microphone audio icon_person click each item to hear a list of vocabulary words from the lesson. then, record yourself sa
    7·2 answers
  • Which of the following is true of information systems?
    15·1 answer
  • . Write a recursive function names factorial to compute the factorial of the parameter. Also write the main function, where you
    15·1 answer
  • Write a script that creates a user-defined database role named OrderEntry in the MyGuitarShop database. Give INSERT and UPDATE p
    8·1 answer
  • Which collaboration technology is becoming more and more popular within organizations because it provides a means for forming ad
    12·1 answer
  • 14.28. Consider the relation R, which has attributes that hold schedules of courses and sections at a university; R = {Course_no
    7·1 answer
  • A laptop gets replaced if there's a hardware issue. Which stage of the hardware lifecycle does this scenario belong to?
    5·1 answer
  • In this code, identify the repeated pattern and replace it with a function called month_days, that receives the name of the mont
    14·1 answer
  • Write a while loop that prints userNum divided by 2 (integer division) until reaching 1. Follow each number by a space. Example
    6·1 answer
  • Which is the correct notation to specify the following inheritance?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!