Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Convert to C# //Price Check.cpp //Uses a two-dimensional array to store a price list; //displays the price associated with a product ID #include #include #include

Convert to C#

//Price Check.cpp

//Uses a two-dimensional array to store a price list;

//displays the price associated with a product ID

#include

#include

#include

#include

using namespace std;

int main()

{ //declare variable and array

string searchForId = "";

string products[5][2] = {{"BX35", "13.00"},

{"CR20", "10.00"},

{"FE15", "12.00"},

{"KW10", "24.00"},

{"MM67", "4.00"}};

//get ID to search for, then convert to uppercase

cout << "Enter ID (X to exit): ";

getline(cin, searchForId);

transform(searchForId.begin(), searchForId.end(), searchForId.begin(), toupper);

while (searchForId != "X")

{

//locate position of product ID in the first column in the array

int row = 0; //keeps track of array subscripts

while (row < 5 && products[row][0] != searchForId)

{

row = row + 1;

}//end while

//if ID was found, display price from the second column in the array

//otherwise, display error message

if (row < 5)

{

cout << setiosflags(ios::fixed) << setprecision(2)

<< "Price for product ID " << products[row][0]

<< ": $" << products[row][1] << endl << endl;

}

else

{

cout << "Invalid product ID" << endl << endl;

}//end if

//get ID to search for, then convert to uppercase

cout << "Enter ID (X to exit): ";

getline(cin, searchForId);

transform(searchForId.begin(), searchForId.end(), searchForId.begin(), toupper);

}//end while

return 0;

}//end of main function

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Rules In Database Systems Third International Workshop Rids 97 Sk Vde Sweden June 26 28 1997 Proceedings Lncs 1312

Authors: Andreas Geppert ,Mikael Berndtsson

1997th Edition

3540635165, 978-3540635161

More Books

Students also viewed these Databases questions

Question

5. Describe the visual representations, or models, of communication

Answered: 1 week ago