in c# how would I do the following please create the following methods: 1. Displ
ID: 3627158 • Letter: I
Question
in c# how would I do the following pleasecreate 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 function 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 and then terminates the
application.
Using these methods, you will construct a program that prompts the user for the following:
1. Your name, which will be a string data type
2. Your age, which will be an integer data type
3. The gas mileage for your car, which will be a double data type
4. Display the collected information
Also, note that the program should contain a well document program header.
Pseudocode
//Program Header
//Program Name: Basic User Interface
//Programmer: Your Name
//CIS247, Week 1 Lab
//Program Description: PROVIDE A DESCRIPTITON OF THE PROGRAM
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 mileage to 2 decimal places
display “Your car MPG is: “ + mileage
call TerminateApplication
end main program
procedure 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”
end procedure
procedure DisplayDivider(string outputTitle)
display “**************** “ + outputTitle + “****************”
end procedure
function GetInput(string inputType) as string
strInput as string
display “Enter the “ + inputType
get strInput
return strInput
end function
procedure TerminateApplication
display “Thank you for using the Basic User Interface program”
exit application
end procedure
Explanation / Answer
Dear, using System; // Name of the class public class CSharp { public void DisplayBasicInformation() { console.writeLine("Welcome To the Basic User Interface Program"); console.writeLine("CIS247, Week 1 Lab"); console.writeLine("Name: YOUR NAME"); console.writeLine("This program accepts user input as a string, then makes the appropriate data conversion"); } public void GetInput() { String myname,myage,Gas; int age; double gas; Console.writeline("Enter your Name"); String name=Console.readLine(); Console.writeline("Enter your Age"); myage=Console.readLine(); age=Int32.parse(myage); Console.writeline("Enter gas milage"); Gas=Console.readLine(); gas=Double.parse(Gas); DisplayDivider(); //calling function } public void DispalyDivider() { Console.writeLine("***NAME ***AGE ***MPG"); Console.writeLine(name+" "+age+" " gas); } public void TerminateProgarm() { system.exit(0); } public static void main(String args[]) { // create an object csh to class CSharp to call its methods CSharp csh=new CSharp(); do{ csh.DisplayBasicInformation()// calling function csh.GetInput(); //calling function Console.writeLine("Enter 0 to terminate") String inp; int char=Int32.parse(inp); if(ch==0) csh.TerminateProgarm(); }while(char!=0) } } Hope this would help you.Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.