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
Reil [10]
3 years ago
11

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

Computers and Technology
1 answer:
zaharov [31]3 years ago
8 0

Answer:

import java.util.Scanner;

public class num10 {

   public static void main(String[] args) {

   Scanner scnr = new Scanner(System.in);

   int num1 = scnr.nextInt();

   int num2 = scnr.nextInt();

   int num3 = scnr.nextInt();

   int num4 = scnr.nextInt();

   int product = num1*num2*num3*num4;

   int average = (num1+num2+num3+num4)/4;

   System.out.println(product+" "+average);

   // Part Two

   double prod = num1*num2*num3*num4;

   double ave =  (double)(num1+num2+num3+num4)/4;

   System.out.printf("%.3f", prod);

   System.out.println();

   System.out.printf("%.3f", ave);

   }

}

Explanation:

As required in the question, four variables are created to hold values for num1, num2,num3,num4.

The product  is evaluated:  int product = num1*num2*num3*num4;

The average is evaluated: int average = (num1+num2+num3+num4)/4;

These are output to the screen

In part two;

The product and average are declared as type double so as to hold floating point number

double ave =  (double)(num1+num2+num3+num4)/4; In order to avoid integer division which discards the remainder, a type casting is performed on the 4 input variables.

Finally using printf method new values of product and average is outputed.

You might be interested in
C2.5 - A group of four pirates has a treasure chest and one unique lock and key for each pirate. Using hardware that is probably
slavikrds [6]

Answer:

Explanation:

All the pirates uses their individual key and lock for the locking down of each the four sides of the lid of to the chest. Among the pirates, if three of them decides to open their latches, they can be able to lift the top by essentially using the fourth (locked) latch as a hinge to open the top. (We have several solutions or ways to do this.)

3 0
3 years ago
How are people using lying today? What are the types of lying? Describe each type.
Alborosie
Lol what ever you are taking i want to take it right now 

6 0
4 years ago
Which number is equivalent to 3e-2?<br> 3<br> 0.3<br> O 30<br> my<br> 0.03
Ipatiy [6.2K]

Answer:

0.03

Explanation:

4 0
3 years ago
"if x and y are odd integers, then x + y is even"
Naddika [18.5K]

Answer:

Hello!

The statement is "if x and y are odd integers, then x + y is even"

and we want to prove it by contradiction.

Suppose that we have x and y odd numbers, and suppose that his addition is odd.

We know that an odd number can be writen as (2n +1) (and a even number can be written as 2n) where n is an integer number; then:

x = (2k + 1) and y = (2m + 1)

and x + y = j, where j is also a odd number, then j = (2h + 1)

then:

2k + 1 + 2m + 1 = 2h + 1

2(k + m) + 2 = 2h + 1

2(k + m) +1 = 2h

if k and m are integers, then k + m is also an integer, suppose that k + m = g

then 2g + 1 = 2h

this says that in odd number is equal to an even number, then we have a contradiction, and the addition of two odd numbers cant be an odd number.

8 0
4 years ago
What are html documents also called?
11Alexandr11 [23.1K]
HyperText Markup Language
4 0
3 years ago
Other questions:
  • 7. While an adjacency matrix is typically easier to code than an adjacency list, it is not always a better solution. Explain whe
    5·1 answer
  • What does hdr stand for?
    6·2 answers
  • In 1–2 sentences describe how you would insert a row in a spreadsheet.
    11·1 answer
  • Many loop control variable values are altered by ____ or adding to them
    11·1 answer
  • A photo's color intensity can be modified by changing the brightness and content.
    9·1 answer
  • AT&amp;T reacted to the popularity of the cellular phone by adding several cellular models to its line of regular phones. Availa
    8·1 answer
  • Which of the following is a windows feature that allows you to temporanily store text
    8·2 answers
  • Create another method: getFactorial(int num) that calculates a Product of same numbers, that Sum does for summing them up. (1,2,
    7·1 answer
  • The term _____ refers to an organization of components that define and regulate the collection, storage, management and use of d
    12·1 answer
  • What are the two different types of dns requests?
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!