Question: Feedback? CHALLENGE ACTIVITY 2 . 8 . 2 : Floating - point numbers ( double ) . 5 8 2 5 4 8 . 4

Feedback?
CHALLENGE
ACTIVITY
2.8.2: Floating-point numbers (double).
582548.4277998 qx324y?
Jump to level 1
One gallon equals 128 fluid ounces. The following program intends to read a floating-point value from input, convert the value from fluid ounces to gallons, and output the volume in gallons, but the code contains errors. Find and fix the errors.
Ex: If the input is 2.7, then the output is:
0.021 gallons234Input 2.7 is a double, but variables volOunces and volGallons are declared as integers. volGallons = volounces /128 performs integer division, so 2.7/128 results in 0. Therefore, volOunces and volGallons should be doubles.Not all tests passed.1: Compare outputOutput differs. See highlights below.Input2.7
 Feedback? CHALLENGE ACTIVITY 2.8.2: Floating-point numbers (double). 582548.4277998 qx324y? Jump to

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!