Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Convert to Java //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 Java

//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

Intelligent Information And Database Systems Asian Conference Aciids 2012 Kaohsiung Taiwan March 2012 Proceedings Part 2 Lnai 7197

Authors: Jeng-Shyang Pan ,Shyi-Ming Chen ,Ngoc-Thanh Nguyen

2012th Edition

3642284892, 978-3642284892

More Books

Students also viewed these Databases questions

Question

what is the main benefit to using audit data analytics?

Answered: 1 week ago

Question

1. What are the pros and cons of diversity for an organisation?

Answered: 1 week ago

Question

1. Explain the concept of diversity and equality in the workplace.

Answered: 1 week ago