1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Aloiza [94]
4 years ago
5

Implement the following logic in C++, Use appropriate data types. Data types are represented as either numeric (num) or string.

Computers and Technology
1 answer:
ICE Princess25 [194]4 years ago
6 0

Answer:

Follows are the modified code in c++ language:

#include<iostream>//header file

#include<string>//header file

using namespace std;

int main()//main method

{

string name,address, MSG_YES, MSG_NO;//defining string variable

int item,quantity,size=6, i=0;//defining integer variable

double price;//defining double variable  

int VALID_ITEM[]={106,108,307,405,457,688};//defining integer array and assign value

double VALID_ITEM_PRICE[]={0.59,0.99,4.50,15.99,17.50,39.00};//defining double array and assign value

bool foundIt=false;//defining bool variable  

MSG_YES="Item available";//use string variable to assign value

MSG_NO = "Item not found"; //use string variable to assign value

cout<<"Input name: ";//print message

cin>>name;//input value in string variable

cout<<"Input Address: ";//print message

cin>>address;//input value in string variable

cout<<"Input Item: "<<endl;//print message

cin>>item;//input value in string variable

cout<<"Input Quantity: "<<endl;//print message

cin>>quantity;//input value in string variable

while(i <size)//defining while that checks i less then size  

{

if (item ==VALID_ITEM[i]) //use if block to match item in double array

{

foundIt = true;//change bool variable value

price = VALID_ITEM_PRICE[i];//hold item price value in price variable  

}

i++;//increment the value of i

}

if (foundIt == true)//use if to check bool variable value equal to true

{

cout<<MSG_YES<<endl;//print value

cout<<"Quantity "<<quantity<<" at "<<"Price "<<price<<"each"<<endl;//print value

cout<<"Total"<<quantity*price;//calculate the total value

}

else//else block

cout<<MSG_NO;//print message  

}

Output:

please find the attached file.

Explanation:

In the above given C++ language modified code, four-string variable " name, address, MSG_YES, and MSG_NO", four integer variable "item, quantity, size, and i", and "integer and double" array is defined, that holds values.

In the string and integer variable "name, address, and item, quantity", we input value from the user-end and use the while loop, which uses the if block to check the "item and quantity" value from the user end and print its respective value.

You might be interested in
What office application has animations on the home ribbon?
Eva8 [605]
It's Microsoft office power point presentation.
3 0
4 years ago
Read 2 more answers
What format should a cover letter be in?
Arisa [49]

Answer:

Cover letters should always be in standard business format!

So it should either be written/typed up on either your own letterhead or with your address block at the top of the page.

Hope this helps

Explanation:

6 0
3 years ago
Read 2 more answers
give the difference between functional and functional tools in the middle of to the circle give importance​
bija089 [108]

Answer:

hakkuna matata is the radious of a circle

5 0
3 years ago
Complete the below function which dynamically allocates space to a 3d array of doubles, initializes all values to 0, and returns
MAVERICK [17]

Answer:

Explanation:

1. double ***alloc3dArrayOfInts( int length, int width, int depth) {

2. double ***array3d = malloc(length * sizeof(double **) );

3. for(int i=0; i< length ;i++) {

4. array3d[i] = malloc(width * sizeof(double *) );

5. for(int j=0; j< width;j++) {

6. array3d[i][j] = malloc(depth * sizeof(double) );

7. }

8. }

9. return array3d;

10. }

5 0
3 years ago
Which Tab provides the command to add a hyperlink to a document?
Natali [406]

Answer:

I love it is your responsibility is accepted the second one was for the database reply to your account we should wear the same same Dp xd I have tow bar is the only one hour u

7 0
3 years ago
Read 2 more answers
Other questions:
  • Why does the hp computer not have Bluetooth?
    6·1 answer
  • 1. You want to schedule a weekly analysis for the Windows servers in your data center. The command should run as a scheduled job
    15·1 answer
  • What is the main benefit of seeing your document in Page Break Preview?
    9·2 answers
  • What does confidentiality of data refer to?
    6·2 answers
  • The IT director instructed the systems administrator to build a server to support the accounting department's file growth. The I
    7·1 answer
  • Can anyone guide me on what to learn after C language?
    15·1 answer
  • Now imagine that we have a list of 5 employees who have each worked 45, 15, 63, 23, and 39 hours. We'll fix rate_of_pay at 10. P
    10·1 answer
  • You are working on a router that has established privilege levels that restrict access to certain functions. you discover that y
    5·1 answer
  • Examples of pop in computer​
    14·1 answer
  • Tools such as microsoft's word, excel, and powerpoint are examples of ________ software. question content area bottom part 1 a.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!