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]
3 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]3 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
Input is information a system uses to monitor and adjust itself to meet the goal.
agasfer [191]
That is a true statement. Hope this was helpful!
7 0
3 years ago
)Which of following can be thrown using the throwstatement?
Amanda [17]

Answer:

All of Given

Explanation:

The throw keywords can be used to throw any Throwable object. The syntax is :

throw <Throwable instance>

Note that Error and Exception are subclasses of Throwable while RuntimeException is a subclass of Exception. So the hierarchy is as follows:

Throwable

-- Error

-- Exception

   -- RuntimeException

And all of these are valid throwable entities. As a result "All of Given" is the most appropriate option for this question.

6 0
3 years ago
Read 2 more answers
Why was 1990 an important year regarding air quality?
fredd [130]

Explanation:

The United States created the Environmental Protection Agency. in some ways they have did that

4 0
3 years ago
Read 2 more answers
. Html documents are created by adding what to text?
zvonat [6]
The answer is Tags, sorry about putting the other answer misread question.
7 0
3 years ago
What is a fixed expense<br> everfi
Gelneren [198K]

Answer:

A fixed expense is an expense that has a constant total expense value (the total amount of the fixed expense) that remains the same (does not change) when there is a change in the number being managed, manufactured, or sold

Examples of fixed  expense includes; depreciation of assets, salaries of workers, payment for rental lease, and some utility payment, such as road users toll fees payment at a toll gate

Explanation:

8 0
2 years ago
Other questions:
  • Which is the most efficient way to italicize a row of text in every worksheet in a workbook?
    8·1 answer
  • The analog signals that carry analog or digital data comprise composites built from combinations of simple sine waves.
    12·1 answer
  • Which of the following are examples of software? Check all of the boxes that apply.
    12·2 answers
  • Implement the function pairSum that takes as parameters a list of distinct integers and a target value n and prints the indices
    11·1 answer
  • What is random access memory?
    6·2 answers
  • Which activity represents a violation of the licensing agreement?
    13·2 answers
  • BEING TIMED HELP ASAP
    12·2 answers
  • What are potential problems with using nanorobots ?
    14·1 answer
  • Describe how to find and replace a text in a document​
    13·1 answer
  • What is the difference between the wiring configurations for a residential, 8-position, 8-contact (8P8C) modular plug and jack i
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!