Pseudocode //Program Header //Program Name: Basic User Interface //Programmer: Y
ID: 3636568 • Letter: P
Question
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
please rate - thanks
//Program Header
//Program Name: Basic User Interface
//Programmer: Your Name
//CIS247, Week 1 Lab
//Program Description: PROVIDE A DESCRIPTITON OF THE PROGRAM
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
void DisplayApplicationInformation();
void DisplayDivider(string );
string GetInput(string );
void TerminateApplication();
int main()
{string input, name;
int age;
double mileage;
DisplayApplicationInformation();
DisplayDivider("Start Program");
DisplayDivider("Get Name");
name = GetInput("Your Name");
cout<<"Your name is: "<<name<<endl;
DisplayDivider("Get Age");
input = GetInput("Your Age");
age = atoi(input.c_str());
cout<<"Your age is: "<<age<<endl;
DisplayDivider("Get Mileage");
input = GetInput("Gas Mileage");
mileage = atof(input.c_str());
cout<<"Your car MPG is: "<<setprecision(2)<<fixed<<mileage<<endl;
TerminateApplication();
system("pause");
return 0;
}
void DisplayApplicationInformation()
{cout<<"Welcome the Basic User Interface Program ";
cout<<"CIS247, Week 1 Lab ";
cout<<"Name: YOUR NAME ";
cout<<"This program accepts user input as a string, then makes the appropriate data conversion ";
}
void DisplayDivider(string outputTitle )
{cout<<"****************" <<outputTitle<<"**************** ";
}
string GetInput(string inputType)
{string strInput;
cout<<"Enter the "<<inputType<<": ";
cin>>strInput;
return strInput;
}
void TerminateApplication()
{cout<<"Thank you for using the Basic User Interface program ";
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.