Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Which piece of code calculates an average - preserving precision - and displays it to 2 decimal places? O int test1 = 90, test2

image

Which piece of code calculates an average - preserving precision - and displays it to 2 decimal places? O int test1 = 90, test2 = 85, test3 = 87, sum; double average; sum = test1 + test2 + test3; average = sum / 3.0; System.out.printf ("The average is %.2f%n", average); int test1 = 90, test2 = 85, test3 = 87, sum; double average; sum test1 + test2 + test3; average = sum / 3; System.out.printf("The average is %f%n", average); O int test1 = 90, test2 = 85, test3 = 87, sum; double average; sum test1 + test2 + test3; average = sum / 3.0; System.out.printf ("The average is %d%n", sum); Oint test1 = 90, test2 = 85, test3 = 87, sum; double average; sum test1 + test2 + test3; average sum / 3; System.out.printf("The average is %.2f%n", average);

Step by Step Solution

There are 3 Steps involved in it

Step: 1

The detailed answer for the above question is provided below The correct code is Java int test1 ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

An Introduction to Programming with C++

Authors: Diane Zak

8th edition

978-1285860114

More Books

Students also viewed these Programming questions