Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

2. Prompt the user for your each of theitems listed in question #1 and read them

ID: 3615711 • Letter: 2

Question

2.     Prompt the user for your each of theitems listed in question #1 and read them in

3.     Display just your last name

4.     Capitalize just the first letter ofyour last name

5.     How would question #4 change if youwanted to upper case ALL letters in your entire name?

6.     Write ONE if statement to find out ifthe first letter of the name is a letter (Something between A toZ); display an error if it is not the case.

7.     Count how many numbers were typed infor the phone number to see if it is correct (there should be 10digits).

8.     Continue with Question #7…Ifthe user did not type in the correct number of digits for the phonenumber, give the user one more chance to get it right

9.     Alternate for Question#7…Write a loop that allows the user to have another chanceto enter in the phone number if it is incorrect; the user shouldhave as many chances as they want – until they get itright!

10. Find out if the 4th character of the phonenumber is a hyphen, eg., “503-725-5394” and if sochange the phone number to have this format: (503) 725-5394

11. Find out if the last 3 characters of the email addressis either .com, .net, or .edu

12. Sometimes, when you type in an email address, you areasked to type it in twice just to make sure you didn’t makeany typos. So, with Question #12, ask the user to type the emailaddress in again – and store it in a different variable. Now,using strcmp (from the cstring library) see if the email addressmatches the version that was first typed in.

13. Show an example where it would be useful to usecin.ignore(100,’ ’);

14. For two of the above questions – re-write them asfunctions showing pass by value and pass by reference.

15. Show how you can call these functions (show allvariables)

#include<iostream>
using namespace std;
int main()

{
string name,last, address,email,phone;
int n,len,i,count,p;
cout<<"Enter your first and last name: ";
getline(cin,name);
cout<<"Enter your address: ";
cin.get(cin,address)
cin.ignore();

cout<<"Enter youremail address: ";
getline(cin,email);
cout<<"Enter your phone number: ";
getline(cin,phone);
n=name.find(' ',0);
len=name.length();
last=name.substr(n+1,len-n);
cout<<"Your last name is: "<<last<<endl;
last[0]=toupper(last[0]);
cout<<"Your last name is: "<<last<<endl;
for(i=0;i<last.length();i++)
    last[i]=toupper(last[i]);
cout<<"Your last name is: "<<last<<endl;
if(last[0]<'A'||last[0]>'Z')
     cout<<"Your last name doesn't startwith a letter ";
i=0;
count=0;
while(phone[i]!='')
   {if(phone[i]>='0'&&phone[i]<='9')
         count++;
    i++;
}
    cout<<"Your phone number is"<<count<<" digits ";
if(count!=10)
    {cout<<"Your phone number is the wronglength-please reenter: ";   
    getline(cin,phone);               //one try to get right
}

do                               //do until it's right
{i=0;
count=0;
while(phone[i]!='')
{
if(phone[i]>='0'&&phone[i]<='9')
count++;
    i++;
}
if(count!=10)
    {cout<<"Your phone number is the wronglength-please reenter: ";   
     getline(cin,phone);
}
}while(count!=10);

if(phone[3]=='-')
{
                p=phone.length();
     for(i=p+1;i>3;i--)
        phone[i]=phone[i-1];
     phone[4]=')';
     for(i=3;i>0;i--)
        phone[i]=phone[i-1];
     phone[0]='(';
     }
cout<<phone<<endl;     
system("pause");
return 0;
}

Explanation / Answer

x.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote