subject
Engineering, 18.11.2019 19:31 ang233499

This program currently fails to compile because the parameters cannot be automatically converted to double in the statement triplesum = item1 + item2 + item3; . because thetype is bound to the class number, the number class' doublevalue() method can be called to get the value of the parameters as a double value. modify tripleavg() method to use the doublevalue() method to convert each of the parameters to a double value before adding them.
public class itemminimum {
public static
double tripleavg(thetype item1, thetype item2, thetype item3) {
double triplesum = 0.0;
triplesum = item1 + item2 + item3;
return triplesum / 3.0;
}
public static void main(string[] args) {
integer intval1 = 55;
integer intval2 = 99;
integer intval3 = 66;
double doubleval1 = 14.5;
double doubleval2 = 12.3;
double doubleval3 = 1.75;
// try tripleavg method with integers
system. out. println("items: " + intval1 + " " + intval2 + " " + intval3);
system. out. println("avg: " + tripleavg(intval1, intval2, intval3) + "\n");
// try tripleavg method with doubles
system. out. println("items: " + doubleval1 + " " + doubleval2 + " " + doubleval3);
system. out. println("avg: " + tripleavg(doubleval1, doubleval2, doubleval3) + "\n");
return;
}
}

ansver
Answers: 2

Other questions on the subject: Engineering

image
Engineering, 04.07.2019 18:10, mm016281
What difference(s) did you notice using a pneumatic circuit over hydraulic circuit. explain why the pneumatic piston stumbles when it hits an obstacle.
Answers: 2
image
Engineering, 04.07.2019 18:10, danksans7011
The mass flow rate of the fluid remains constant in all steady flow process. a)- true b)- false
Answers: 1
image
Engineering, 04.07.2019 18:10, viicborella
Steel is coated with a thin layer of ceramic to protect against corrosion. what do you expect to happen to the coating when the temperature of the steel is increased significantly? explain.
Answers: 1
image
Engineering, 04.07.2019 18:10, jadeochoa4466
The temperature of air decreases as it is compressed by an adiabatic compressor. a)- true b)- false
Answers: 2
You know the right answer?
This program currently fails to compile because the parameters cannot be automatically converted to...

Questions in other subjects: