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

#include <iostream> #include <string> using namespace std; int main() { const in

ID: 3816943 • Letter: #

Question

#include <iostream>
#include <string>
using namespace std;


int main()
{
   const int sentinel = -1;
   int itemNum;

   int itemNo[]={341,342,343,344,345,346};
   string itemNames[]={"Shirt", "Blouse", "Jeans", "Trousers","Hat", "Chain"};
   double cost[]={34.5,12.67,78.6,20,15,208.78};

do
{
   cout << "Enter a number between 1 to 6" " ";
   cin >> itemNum;

   switch (itemNum)
   {
   case 1:
   case 2:
   case 3:
   case 4:
   case 5:
   case 6:
       {
           cout << "The itemNo is: " << itemNo[itemNum -1] << endl;
           cout << "You have chose " << itemNames[itemNum -1] << endl;
           cout << "Its cost is $ " << cost[itemNum -1] << endl;
           break;
       }
   case -1 :
       { break;
       }
   default : {
       cout << "Invalid!!! must be an integer between 1 and 6 (inclusive)" << endl;
       break;
}
   }
} while( itemNum != sentinel);
   return 0;
}

Modify the program to ask the user if heshe would like to pick another item. If Y or Yes let them do so and print the array information associated with the item. If N or No then end the program by saying "Thank you for using our selector".

Explanation / Answer

#include <iostream.h>
#include<string.h>

int main()
{

int i;
int itemNum;
char contChoice;
int itemNo[]={341,342,343,344,345,346};
string itemNames[]={"Shirt", "Blouse", "Jeans", "Trousers","Hat", "Chain"};
double cost[]={34.5,12.67,78.6,20,15,208.78};
do
{
for(i=0;i<6;i++){
cout<<(i+1)<<". "<<itemNames[i]<<" - $"<<cost[i]<<endl;
}
cout << "Enter a number between 1 to 6" " ";
cin >> itemNum;
if(itemNum<7 && itemNum>0){
cout << "The itemNo is: " << itemNo[itemNum -1] << endl;
cout << "You have chose " << itemNames[itemNum -1] << endl;
cout << "Its cost is $ " << cost[itemNum -1] << endl;
}
else{
cout<<"Invalid!!! must be an integer between 1 and 6 (inclusive)"<<endl;
}

cout<<"Want to pick another item? (Y/N)"<<endl;
cin>>contChoice;
  
} while( contChoice=='Y');

cout<<"Thank you for using our selector";

return 0;
}