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

what is the code to make this work in C++? Lab 6 (60 points) Chapter 10: Charact

ID: 3716333 • Letter: W

Question

  



what is the code to make this work in C++?

Lab 6 (60 points) Chapter 10: Characters, C-Strings, and More About the string Class Independent Study This assignment willbe graded on the basis of completion and effort Turn in the .cpp file and appropriate screenshots in Canvas. Create a program that shows various e-string manipulation techniques. This lab should be implemented as a menu driven program that calls various functions that demonstrate your understanding of character arrays, c-strings and the string class in main)-create a menu with 5 options Doing Math with Strings Counting Elements C-String Manipulation String Class Manipulation Exit Program 1. 2. 3, 4. 5. Loop though the menu unti the user selects to ext the program. You may use numbers or letters to indicate the menu options. Test that the user enters in a valid option. If they do not enter a valid option, tell the user their selection is invalid and allow them to reenter the option. The menu will continue to loop until a valid option is entered. Wnite a function called stringMath. . The function should ask the user to input a value that represents the number of weeks as a . Then, ask the user to enter in the number of hours per day that they work and their hourly . Convert the string to integers or doubles as appropnate. string pay rate (again, enter as strings) 5 working days per week). . Calculate and display the total number of working days in those weeks (there are a constant culate the weekly pay (number of hours per day" 5 days per week hourly rate). . Then calculate the total amount eamed for the entered number of weeks. Display the pay per week and the total amount earned Finally, the function should Validate the input (the only valid values are "Y" and "N convert the input to upper case in the trap) and write the code that will allow for another set of calculations (again converting the input to upper case). Extra credit will be awarded i the program validates that the number of weeks, the numbe of hours per day and the houry pay rate are tested for validity upon entry

Explanation / Answer

#include<iostream>

#include<cstdio>

using namespace std;

void mathfunction()

{

int week;

int no_wrkdays;

cout<<"enter the number of weeks :";

cin>>week;

int hours;

float payrate;

float pay_amount;

float total_pay;

cout<<"enter the number of hours per day: ";

cin>>hours;

no_wrkdays=5*week;

cout<<"the number of working days: ";

cout<<no_wrkdays;

cout<<"please enter the pay rate: ";

cin>>payrate;

pay_amount=payrate*no_wrkdays;

cout<<"theweekly pay amount is: ";

cout<<pay_amount;

cout<<"total pay for a week ";

total_pay=pay_amount+week;

cout<<total_pay;

}

void count_element()

{

char ch[100];

gets(ch);

gets(ch);

cout<<ch;

int count=0,digitcount=0,lowerflag=0,upperflag=0;

for(int i=0;ch[i]!='';i++)

{

if(ch[i]>='a' && ch[i]<='z')

{

count++;

}

if(ch[i]>='A' && ch[i]<='Z')

{

count++;

}

}

for(int i=0;ch[i]!='';i++)

{

if(ch[i]>='a' && ch[i]<='z')

{

lowerflag++;

}

}

for(int i=0;ch[i]!='';i++)

{

if(ch[i]>='A' && ch[i]<='Z')

{

upperflag++;

}

}

for(int i=0;ch[i]!='';i++)

{

if(ch[i]>='0' && ch[i]<='9')

{

digitcount++;

}

}

cout<<"the number of alphas in the given string:"<<count<<endl;

cout<<"the number of uppercase in the given string:"<<upperflag<<endl;

cout<<"the number of lowercase in the given string:"<<lowerflag<<endl;

cout<<"the number of digits in the given string:"<<digitcount<<endl;

}

//void

int main()

{

int n;

cout<<"enter the choice: ";

cout<<"1-Doing math with strings ";

cout<<"2-Counting elements";

cout<<"3-C-string manipulation ";

cout<<"String class manipulation ";

cout<<"Exit program ";

while(1)

{

cin>>n;

switch(n)

{

case 1:

mathfunction();

break;

case 2:

count_element();

break;

}}

return 0;

}