Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

WGU Scripting and Programming Foundations (D278) Exam - Topic 4 Question 16 Discussion

Posted by Karon on Aug 19, 2026 at 02:47 AM

A program calculates the average miles per gallon given miles traveled and gas consumed

How should the item that holds me miles per gallon be declared?

Suggested Answer: B

In a program that calculates the average miles per gallon based on miles traveled and gas consumed, the item that holds the miles per gallon should be declared as a variable because it will change depending on the input values. The data type should be a floating-point number (float) because miles per gallon is a value that can have a fractional part, and it is not a fixed value, hence it should not be a constant.


Best practices in programming suggest using variables for values that change and constants for values that remain the same throughout the program execution.

The concept of variables and data types is fundamental in programming and is covered in foundational programming documentation and textbooks.

Get Premium Scripting and Programming Foundations (D278) Questions as Interactive Web-Based Practice Test or PDF Real Exam Format Detailed Explanations Instant Access Get Your Practice Test
12 comments · newest first
ME
Melina 3 days ago
Definitely B, MPG can vary based on gas used.
CE
Celestine 8 days ago
I think A makes sense too, MPG shouldn't change.
LI
Lili 13 days ago
B is the right choice, we need a variable for MPG.
DI
Diane 18 days ago
B is the best choice, MPG needs to be calculated.
HA
Hailey 23 days ago
Wait, can MPG really be a constant? Seems off.
CO
Cordie 29 days ago
A is wrong, miles traveled isn't constant.
TA
Tawny 1 month ago
I think D makes more sense, MPG shouldn't change.
EL
Elizabeth 1 month ago
Definitely B, you need a variable for MPG.
NU
Nu 1 month ago
I’m confused about the difference between milesTraveled and milesPerGallon. I guess milesPerGallon should be variable, but I’m not completely confident.
CA
Catrice 2 months ago
This reminds me of a practice question where we had to declare variables for calculations. I feel like B makes the most sense.
CR
Cristy 2 months ago
I'm not entirely sure, but I remember something about constants being used for fixed values.
FR
Francine 2 months ago
I think it should be a variable since the miles per gallon can change based on input values.
0/2000 characters

Save Cancel