subject

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

Ex: If the input is:

8 10 5 4
Given:

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;
/* Type your code here. */
}
}

the output is:

1600 6
Note: Integer division discards the fraction. Hence the average of 8 10 5 4 is output as 6, not 6.75.

Note: The test cases include four very large input values whose product results in overflow. You do not need to do anything special, but just observe that the output does not represent the correct product (in fact, four positive numbers yield a negative output; wow).

Submit the above for grading. Your program will fail the last test cases (which is expected), until you complete part 2 below.

Part 2

Also output the product and average, using floating-point arithmetic.

Output each floating-point value with three digits after the decimal point, which can be achieved as follows:
System. out. printf("%.3f", yourValue);

Ex: If the input is 8 10 5 4, the output is:

1600 6
1600.000 6.750
Note that fractions aren't discarded, and that overflow does not occur for the test case with large values.

LAB

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 21:00
Alcohol’s affects on the cornea and lens of the eye make it more difficult
Answers: 1
question
Computers and Technology, 25.06.2019 08:50
A-12.3 an american spy is deep undercover in the hostile country of phonemia. in order not to waste scarce resources, any time he wants to send a message back home, he removes all the punctuation from his message and converts all the letters to uppercase. so, for example, to send the message, “abort the plan! meet at the dark cabin.” he would transmit given such a string, s, of n uppercase letters, describe an efficient way of breaking it into a sequence of valid english words. you may assume that you have a function, valid(s), which can take a character string, s, and return true if and only if s is a valid english word. what is the running time of your algorithm, assuming each call to the function, valid, runs in o(1) time?
Answers: 3
question
Computers and Technology, 25.06.2019 09:20
The adbusters' image of the gap logo on the silhouette of a head most likely relays the message that: a.the man in the ad needs a hat from the gap b.consumers should be suspicious of gap ads c.gap clothes make you look intelligent d.everyone should have the gap on their minds
Answers: 1
question
Computers and Technology, 25.06.2019 11:30
The main benefit of encryption of a hard drive
Answers: 1
You know the right answer?
Given 4 integers, output their product and their average, using integer arithmetic.

Ex:...
Questions
question
Mathematics, 12.02.2021 02:40
question
Mathematics, 12.02.2021 02:40
question
History, 12.02.2021 02:40
question
Mathematics, 12.02.2021 02:40
question
Mathematics, 12.02.2021 02:40
question
Mathematics, 12.02.2021 02:40
Questions on the website: 13722363