Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In this program, you will create the following methods: 1. DisplayApplicationInf

ID: 3639940 • Letter: I

Question

In this program, you will create the following methods:
1. DisplayApplicationInformation, which will provide the program user some basic
information about the program.
2. DisplayDivider, which will provide a meaningful output separator between different
sections of the program output.
3. GetInput, which is a generalized method that will prompt the user for a specific type
of information, then return the string representation of the user input.
4. TerminateApplication, which provides a program termination message.
Using these methods, you will construct a program that prompts the user for the following:
1. Their name, which will be a string data type
2. Their age, which will be an integer data type
3. The gas mileage for their car, which will be a double data type
4. Display the collected information
Also, note that the program should contain a well-documented program header such as
below.
//Program Header
//Program Name: Basic User Interface
//Programmer: Your Name
//CIS247, Week 1 Lab
//Program Description: PROVIDE A DESCRIPTION OF THE PROGRAM
You will need to translate the following pseudocode into code. Make sure you provide
meaningful comments.
Pseudocode
Start Main
//declare variables
input as string
name as string
age as integer
mileage as double
call DisplayApplicationInformation()
call DisplayDivider(“Start Program”)
call DisplayDivider(“Get Name”)
set name = GetInput(“Your Name”)
display “Your name is: “ + name
call DisplayDivider(“Get Age”)
set input = GetInput(“Your Age”)
set age = convert input to integer
display “Your age is: “ + age
call DisplayDivider(“Get Mileage”)
set input = GetInput(“Gas Mileage”)
set mileage = convert input to double
display “Your car MPG is: “ + mileage
call TerminateApplication()
end Main program
method DisplayApplicationInformation()
display “Welcome the Basic User Interface Program”
display “CIS247, Week 1 Lab”
display “Name: YOUR NAME”
display “This program accepts user input as a string, then makes the appropriate
data conversion and displays the results”
end method
method DisplayDivider(string outputTitle)
display “**************** “ + outputTitle + “****************”
end method
method GetInput(string inputType) returns a string
strInput as string
display “Enter the “ + inputType
get strInput
return strInput
end method
method TerminateApplication()
display “Thank you for using the Basic User Interface program”
end method


**************So far here is my program*********************
package week1;
import javax.swing.JOptionPane;
public class MainClass {


public static void main(String[] args)
{
String name = "";
String input="";
int age = 0;
double mileage = 0;
displayApplicationInformation();
displayDivider("Start Program");

displayDivider("Get Name");
name = getInput("Please enter your name");
System.out.println("Your name is " + name);

displayDivider("Get Age");
input = getInput("Please enter your age");
age = Integer.parseInt(input);
System.out.println("Your age is " + age);

displayDivider("Get mileage");
input = getInput("Enter Mileage");
mileage = Double.parseDouble(input);
NumberFormat nf = NumberFormat.getCurrencyInstance();
System.out.println("Your mileage is "+ nf.format(mileage));
System.out.printf("Mileage = %99.2f", mileage);
TerminateApplication();





} //end of main

// This method will display basic program info
public static void displayApplicationInformation()
{
System.out.println("Welcome to the Basic User Interface");
System.out.println("CIS247B");
System.out.println("Name: Sharon Dearman");

} // end of display

public static void displayDivider (String in)
{
System.out.println("******* " + in + " *******");

}

public static String getInput(String in)
{
String s = JOptionPane.showInputDialog(in);
return s;

}



} //end of MainClass

Explanation / Answer

please rate - thanks

changes made are in red

import javax.swing.JOptionPane;
public class MainClass {


public static void main(String[] args)
{
String name = "";
String input="";
int age = 0;
double mileage = 0;
displayApplicationInformation();
displayDivider("Start Program");

displayDivider("Get Name");
name = getInput("Please enter your name");
System.out.println("Your name is " + name);

displayDivider("Get Age");
input = getInput("Please enter your age");
age = Integer.parseInt(input);
System.out.println("Your age is " + age);

displayDivider("Get mileage");
input = getInput("Enter Mileage");
mileage = Double.parseDouble(input);
//NumberFormat nf = NumberFormat.getCurrencyInstance();
//System.out.println("Your mileage is "+ nf.format(mileage));
System.out.printf("Your car MPG is: %5.2f ", mileage);
TerminateApplication();

} //end of main

public static void TerminateApplication()
{System.out.println("Thank you for using the Basic User Interface program");
}

// This method will display basic program info
public static void displayApplicationInformation()
{
System.out.println("Welcome to the Basic User Interface");
System.out.println("CIS247B");
System.out.println("Name: Sharon Dearman");

} // end of display

public static void displayDivider (String in)
{
System.out.println("******* " + in + " *******");

}

public static String getInput(String in)
{
String s = JOptionPane.showInputDialog(in);
return s;

}



} //end of MainClass

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote