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
Consider the following method: public double doubleVal(double x) { return x *2; } The following code segment calls the method do
VashaNatasha [74]

Answer:

13.0

Explanation:

The method doubleVal() is created to accept a single parameter of type double.

It multiplies what ever the value of the parameter is and returns the resulting value.

In this question The method is called within this output statement System.out.println(doubleVal(val)); (Note that val had already been declared and assigned the value of 6.5)

The value 6.5 is doubled and outputed to the screen

8 0
3 years ago
When does patch 1.6 come out for the division?
Fynjy0 [20]
Thurdsay the 9th of february 
5 0
3 years ago
Estate settlement is provided by banks through
natali 33 [55]
I believe the trust department.
8 0
4 years ago
Pleaseeeeeeee tellllllllllllllllllllll​
Oksana_A [137]

Answer:

digital communications will be the correct answer

3 0
3 years ago
Read 2 more answers
Which city is the largest within the Andean and midlatitude countries? A. Buenos Aires, Argentina B. La Paz, Bolivia C. Santiago
Westkost [7]
My best guess would be either B. or C. 
Hope I helped:)
8 0
3 years ago
Read 2 more answers
Other questions:
  • In today's society, unethical actions are: A) Easier than ever to get away with, because the general public and insurers are les
    13·2 answers
  • Each character in a string has a(n) _______________ which specifies its position in the string.
    13·1 answer
  • Which of the following statements is true?
    5·1 answer
  • What is the FTC used car rule
    12·1 answer
  • What section of the outline is represented by "A. Africa?"
    11·2 answers
  • Time
    6·1 answer
  • Implement the above in c++, you will write a test program named create_and_test_hash.cc . Your programs should run from the term
    9·1 answer
  • Advantages of a grain crush​
    9·1 answer
  • Which type of app is the best choice when it is critical to be able to use the device's features but performance is not critical
    10·2 answers
  • Write a program that accepts a whole number as input, multiplies that number by 12, and then outputs the product.
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!