I am studying OOP right now and the last time I used C++ was 2 years ago when I
ID: 3631797 • Letter: I
Question
I am studying OOP right now and the last time I used C++ was 2 years ago when I studied it for the class. It has been too long and I forgot almost everything :( So, I am teaching myself again but running out of time for our assignment:This program creates the basic user interface code that can be used in the following week's iLab assignments. The assignment will help you get started using the programming environment and some practice with coding. You will also be able to reuse much, if not all, of the code in later assignments.
In this program, you will create the following methods:
DisplayApplicationInformation, which will provide the program user some basic information about the program.
DisplayDivider, which will provide a meaningful output separator between different sections of the program output.
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.
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:
your name, which will be a string data type;
your age, which will be an integer data type;
the gas mileage for your car, which will be a double data type; and
a display of the collected information.
Also, note that the program should contain a well-documented program header.
I saw a similar program here but that was in C# ..please help! If you do it I can then back engineer it and learn from it.
Someone HELPED ME in C# ...I need it in C++ PLEASE!!!
Explanation / Answer
please rate - thanks
#include <iostream>
#include <string>
using namespace std;
void DisplayApplicationInformation();
void DisplayDivider(string);
string GetInput(string);
void TerminateApplication();
int main()
{string input,name;
int age;
double gas;
DisplayApplicationInformation();
DisplayDivider("get and convert input");
name=GetInput("your name");
input=GetInput("your age");
age=atoi(input.c_str());
input=GetInput("the gas mileage of your car");
gas=atof(input.c_str());
DisplayDivider("display information");
cout<<"name: "<<name<<endl;
cout<<"age: "<<age<<endl;
cout<<"cars gas mileage: "<<gas<<endl;
DisplayDivider("exit");
TerminateApplication();
}
void DisplayApplicationInformation()
{cout<<"This program creates the basic user interface code that can be used in the ";
cout<<"following week's iLab assignments. The assignment will help you get started ";
cout<<"using the programming environment and some practice with coding. You will ";
cout<<"also be able to reuse much, if not all, of the code in later assignments. ";
}
void DisplayDivider(string mess)
{cout<<" --------------------------------------------------------- ";
cout<<mess<<endl<<endl;
}
string GetInput(string mess)
{string input;
cout<<"enter "<<mess<<": ";
cin>>input;
return input;
}
void TerminateApplication()
{cout<<"program complete ";
system("pause");
system("exit");
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.