Question: Objective a . display the column headers Gallon and Litter outside the for loop ( look at the sample output b . Create a for
Objective a display the column headers "Gallon" and "Litter" outside the for loop look at the
sample output
b Create a for loop looping through numbers to decrementing the counter by
Loop control variable represents the number of the gallons. inside this loop do the
following for going down by
i declare a variable of type double Choose a proper name to hold the litter
amount
ii calculate the litter amount and store it in the variable that you just declared
Class constant must be used here gallon is litter
iii. declare another variable to hold the number of ounces. Covert the gallon to
ounces and store it in this variable. gallon is ounces.
iv display the content of the loop control variable gallon and display the litter
amount, and ounce amount that was calculated. Type casting must be used
to get rid of the decimal points.
Main method: in this method do the following
a call the method #
b call the method #
Type Casting
Type casting can be used to get rid of the decimal points in a double value. for example, if
System.out.println intx will display Obviously, this is not a good way to round our
numbers but we will learn the better way in the future.
Sample output is in the next page
Sample output: This program converts the gallons to litters and gallon to ounces
One gallon is equal to litter
One gallon is ounces
MMM
In this assignment you will be practicing for loops, class constant, variable's scope.
Problem
Create an application to convert the gallon to litter.
One gallon is equal to litter. As an example, gallons litter
gallon is equal to ounces
Requirements
In this assignment you are required to created names for the java class and all the methods.
Make sure to follow the naming rules and conventions.
your program must satisfy all the criteria provided in the rubrics including the indentation, block
comments, comments throughout the code, and proper naming.
your program must include methods
the output of your program must be correct and must match the provided output
you can modify the provided shell but make sure that you are not changing the assignment and
its functionalities. You can implement the code based on your logic.
Must decompose the problem into different methods.
Work submitted with just the main method will receive very little partial credit or no credit at all
The name of the methods must be created by you. Names such as method or method is not
accepted
Required class constant variable
Declare a class constant to hold the value for What should be the name for the class
constant? What is the naming convention for a class constant?
The name of a class constant should be all capitalized. If there are more than one words
in the selected name, sperate the words using an underscore. for example, TAXRATE is
a valid class constant name.
This class constant must be used in your code instead of
Declare another class constant to hold the amount Since gallon is ounces.
Required methods Choose proper names for each
method
Method #: this method displays a description of the app on the screen. Make sure to provide
a clear description. Also, the displayed description should be surrounded by or any other
characters of your choice see the sample output You are required to use a for loop to print the
Codes like System.out.println will not be accepted.
Method #: This method converts the gallon to litters and creates a table. See the sample
output. In this method do the following:
Template code pleaswe use:
Name:
date:
Description of what this program does
self grade:
public class ChooseYourName must change this name and then save it with the new name
Declare the required class constant here
public static void main String args
your code, call methods # and #
Explain what the method # deos as a comment here
public static void method rename to a meaningful name
your code for the method #
provide a description of the method #
public static void method must chnage the method name to a meaningful name
Your code for the method #
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
