c++ code
#include <iostream>
#include <string>
using namespace std;
string convertDate(string americanDate)
{
int firstspacepos=0,firstcommapos=0;
for(int i=0; i<americanDate.length(); i++)
{
if(americanDate[i]==' ')
{
firstspacepos=i;
break;
}
}
for(int i=0; i<americanDate.length(); i++)
{
if(americanDate[i]==',')
firstcommapos=i;
}
string internationaldate="";
for(int i=firstspacepos+1; i<firstcommapos; i++)
{
internationaldate+=americanDate[i];
}
internationaldate+=" ";
for(int i=0; i<firstspacepos; i++)
{
internationaldate+=americanDate[i];
}
for(int i=firstcommapos+1; i<americanDate.length();i++)
{
internationaldate+=americanDate[i];
}
return internationaldate;
}
int main()
{
string americanDate;
cout<<"Enter american date: ";
getline(cin,americanDate);
cout<<"Converted date: ";
cout<<convertDate(americanDate)<<endl;
return 0;
}
Sample output
Enter american date: January 25, 1990
Converted date: 25 January 1990
Enter american date: November 2, 1989
Converted date: 2 November 1989
Enter american date: March 08, 1996
Converted date: 08 March 1996
QUESTION 6 15 marks In this question you have to write a C++ program to convert...
In this question you have to write a C++ program to convert a date from one format to another. You have to write a complete program consisting of a main() function and a function called convertDate(). The function receives a string of characters representing a date in American format, for example December 29, 1953. The function has to convert this date to the international format. For example: If the string December 29, 1953 is received, the string that the function...
QUESTION 6 15 marks In this question you have to write a C++ program to convert a date from one format to another. You have to write a complete program consisting of a nain() function and a function called convert Datel). The function receives a string of characters representing a date in American format, for example December 29, 1953. The function has to convert this date to the international format. For example: If the string December 29, 1953 is received,...
QUESTION 6 15 marks In this question you have to write a C++ program to convert a date from one format to another. You have to write a complete program consisting of a nain() function and a function called convert Datel). The function receives a string of characters representing a date in American format, for example December 29, 1953. The function has to convert this date to the international format. For example: If the string December 29, 1953 is received,...
QUESTION 6 15 marks In this question you have to write a C++ program to convert a date from one format to another. You have to write a complete program consisting of amain () function and a function called convertDate(). The function receives a string of characters representing a date in American format, for example December 29, 1953. The function has to convert this date to the international format. For example: If the string December 29, 1953 is received, the...
in c++ In this question you have to write a C++ program to convert a date from one format to another. You have to write a complete program consisting of a main()function and a function called convertDate(). The function receives a string of characters representing a date in American format, for example December 29, 1953. The function has to convert this date to the international format. For example: If the string December 29, 1953 is received, the string that the...
Write a program that prompts the user to input a string. The program then uses the function substr to remove all the vowels from the string. For example, if str=”There”, then after removing all the vowels, str=”Thr”. After removing all the vowels, output the string. Your program must contain a function to remove all the vowels and a function to determine whether a character is a vowel. #include <iostream> #include <string> using namespace std; void removeVowels(string& str); bool isVowel(char ch);...
c++, use the skeleton code to make a program of the
following
include <iostream> tinclude <string> using namespace std; class car public: //define your functions here, at least 5 private: string name; int mpg; double price int horsepower; // feel free to add more atributes int main() // create you objects, call your functions // define member functions here For this lab, write a program that does the following: Creates a class based on the car skeleton code (you may...
Im writing a c++ program to translate a sentence to pig latin. But I keep getting an error where it only prints out the "ay" part. Not sure where I'm wrong here. string piglatin(string); string substr(string, int&); int main () //begin main { string input; cout<<"Enter a sentence to convert: "; getline(cin, input); cout<<"Converted to Pig Latin: "<<piglatin(input)<<endl<<endl; //cout << "Search for another value? (Y/N)"; //to convert again system("pause"); return 0; } string piglatin(string input) //piglatin function { int len,...
1 Problem Description Instructions. You are provided one skeleton program named LCS.java . The source files are available on Canvas in a folder named HW6 . Please modify the skeleton code to solve the following tasks. • Task 1 (100 pts). Implement the lcs length() function as discussed in Lecture 11. • Note: You should not return the double-array b and c as in the pseu- docode. Instead, return the length of the longest common subsequence. • Hint: To get...
CONVERT THE FOLLOWING C/C++ PROGRAM INTO JAVA: //LinkedString.h #pragma once #include<iostream> #include<string> using namespace std; //declare a node datastruct struct Node { char c; Node *next; }; class LinkedString { Node *head; public: LinkedString(); LinkedString(char[]); LinkedString(string); char charAt(int) const; string concat(const LinkedString &obj) const; bool isEmpty() const; int length() const; LinkedString substring(int, int) const; //added helper function to add to linekd list private: void add(char c); };...