Finish the program. Follow the program logic and then complete the algorithm in the function. Use the programs given constructs and variables only.
#include <iostream>
#include <string>
using namespace std;
// Prototype
string format(string);
int main()
{
// The following string will hold the user's input.
string userDate;
// The following string will hold the formatted date.
string formattedDate;
// Get a date from the user.
cout << "Enter a date in the form mm/dd/yyyy: ";
cin >> userDate;
// Format the date.
formattedDate = format(userDate);
// Display the formatted date.
cout << "You entered " << formattedDate <<
endl;
return 0;
}
// The format function accepts a date in the form mm/dd/yyyy
// as a string, and returns the date in the form March 12,
2014.
string format(string date)
{
int month; // To hold the numeric month
string temp; // Temporary storage
string result; // To hold the formatted date
// The following string array holds the names of
// the months.
string months[] = {"January", "February", "March", "April", "May",
"June", "July", "August", "September",
"October", "November", "December" };
YOUR CODE HERE....
}
C++ CODE :
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
// Prototype
string format(string);
int main()
{
// The following string will hold the user's input.
string userDate;
// The following string will hold the formatted date.
string formattedDate;
// Get a date from the user.
cout << "Enter a date in the form mm/dd/yyyy: ";
cin >> userDate;
// Format the date.
formattedDate = format(userDate);
// Display the formatted date.
cout << "You entered " << formattedDate <<
endl;
return 0;
}
// The format function accepts a date in the form mm/dd/yyyy
// as a string, and returns the date in the form March 12,
2014.
string format(string date)
{
int month; // To hold the numeric month
string temp; // Temporary storage
string result; // To hold the formatted date
// The following string array holds the names of
// the months.
string months[] = {"January", "February", "March", "April", "May",
"June", "July", "August", "September",
"October", "November", "December" };
std::string str2 = date.substr (0,2); // "month"
temp = date.substr (3,2)+" , "+ date.substr (6,4); // "day ,
year"
istringstream ( str2 ) >> month; // convert string to int
type
result = months[month-1]+" "+temp;
return result;
}
OUTPUT :

Finish the program. Follow the program logic and then complete the algorithm in the function. Use...
In C++ Consider the following Date class: #include <iostream> using namespace std; class MyDate { private: int month, day, year; public: MyDate() {setDate(2,27,2006);} MyDate(int, int, int); void setDate(int mm, int dd, int yyyy); void showDate(); }; MyDate::MyDate(int mm, int dd, int yyyy) { month = mm; day = dd; year = yyyy; }; void MyDate::setDate(int mm, int dd, int yyyy) { month = mm; day = dd; year = yyyy; }; void MyDate::showDate() { cout << "The date is "...
Program a clean_string function that combines both the convert_lower and remove_punct functionality in one function. In other words, take a string as a parameter and return a clean version of the string that has no punctuation, no spaces and is all lower case. #include <iostream> #include <string> using namespace std; // TODO: Add your clean_string function here int main() { string line; getline(cin, line); while(line != "quit") { cout << clean_string(line) << ": " << line << endl;...
Complete a partially written C++ program that includes a function that return a value. The program is a simple calculator that prompts the user of 2 number and an operation (+, -, * or, /). The two number and the operator are passed to the function where the appropriate arithmetic operation is performed. The result is return to the main function () where the arithmetic operation and result are displayed. For example 3 * 4 = 12 The source code...
Python
3. Date Printer Write a program that reads a string from the user containing a date in the form mm/dd/yyyy. It should print the date in the format March 12, 2018
3. Date Printer Write a program that reads a string from the user containing a date in the form mm/dd/yyyy. It should print the date in the format March 12, 2018
Transform the find function of Question 4 into a function template. Here is the program used to test your template, followed by the output of that program: #include <iostream> #include <string> #include "find.h" using namespace std; #define NUM_ELEMENTS(a) (sizeof(a) / sizeof(a[0])) int main() { cout << "int" << endl; cout << "---" << endl; int arr1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9}; cout << "3 is at location " << find(arr1, NUM_ELEMENTS(arr1),...
Question 19 4 pts Using the program below, please complete the program by adding 2 functions as follow: 1. A function named getAverage that calculates and returns the Average. 2. A function named getMaximum that returns the maximum of the three numbers. Make sure to use the proper data types for all variables and functions. #include <iostream> using namespace std; //function getAverage //function getMaximum int main(int argc, char** argv) { int x, y, z; cout << "Enter three whole numbers:...
#include <iostream> #include <string> using namespace std; //Write a function that changes all characters in a string to dashes string to_dash(string s){ for(int i = 0; i < s.length(); i++){ } return s; } int main(){ string s; cin >> s; s = to_dash(s); cout << s << endl; }
/* * Program5 for Arrays * * This program illustrates how to use a sequential search to * find the position of the first apparance of a number in an array * * TODO#6: change the name to your name and date to the current date * * Created by Li Ma, April 17 2019 */ #include <iostream> using namespace std; //global constant const int ARRAY_SIZE = 10; //TODO#5: provide the function prototype for the function sequentialSearch int main() {...
Create a program with the main function and one additional function. The additional function asks for input from the user and returns the output back to the main function for display. This is for c++ and here is my code, could you guys please tell me what I am missing from the instructions. Thank you #include <iostream> using namespace std; int sum (int, int); int main() { int n1, n2, total; cout << "Enter two numbers...
// This program displays a menu and asks the user to make a 2 // selection. An if/else if statement determines which item 3 // the user has chosen. 4 #include <iostream> 5 #include <iomanip> 6 using namespace std; 7 8 int main() 9 { 10 int choice; // To hold a menu choice 11 int months; // To hold the number of months 12 double charges; // To hold the monthly charges 13 14 // Constants for membership rates...