Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions