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
Create a method to search an un-ordered array of integers for a value, if the value is found return the index of its position in
Hatshy [7]

Answer:

Following are the program in C++ language  

#include <iostream> // header file

using namespace std; // namespace

int search(int s[],int s1,int n) // function search  

{

   for (int k= 0; k<n; k++) // iterating over the loop

 {

   if (s[k] == s1)   // searching the element  

   {

   return(k); // return the index

     break;

   }

 

}

return(-1); // return(-1)

}

int main() // main function

{

int arr[100],n1,i,s; // variable declaration  

cout<<"Enter number you want in the array:";

cin>>n1;

cout<<"Enter the elements in the array\n ";

for (i = 0; i<n1; i++)

{

   cin>>arr[i]; // taking input into the array  

}

 cout<<"Enter a number you want to search: ";

cin>>s; // read the serach element by the user  

int res= search(arr,s,n1); // calling function search

cout<<res; // display result

 return 0;

}

Output:

Enter number you want in the array:3

Enter the elements in the array

1

2

34

Enter a number you want to search: 2

2

Explanation:

Following are the description of the program  

  • Read the number you want in array in the "n1" variable of int type.
  • Read the array by the user in the "arr ".
  • Read the searching element in the  "s" variable.
  • calling the function search by passing array arr, searching element "s" and "n1".
  • In the search function, it returns the index of its position in the array, if not found then it return -1.
  • Finally print the index.  

6 0
3 years ago
Unscramble the risks of sharing files on the Intern
Zinaida [17]

Answer:

Broken Firewall, Piracy, Malware, Virus, adware

Explanation:

Please give brainliest if this helps

4 0
3 years ago
All of the following items could be too expensive for someone with only a high school degree to afford except
Papessa [141]
This sounds like a multiple choice answer can I have 4 choices to pick?
7 0
3 years ago
A set of blocks contains blocks of heights 1,2, and 4 centimeters. Imagine constructing towers of piling blocks of different hei
SashulF [63]

Answer:

In studies about new medicines, researchers usually give one group of patients the medicine that is designed to treat an illness. They give another group of patients a placebo, which is taken the same way as the medicine but does not actually contain the ingredients of any medicine. Different medicines are tested in different experiments, but the placebos usually contain the same non-medical ingredients. If both groups of patients are healed, then researchers cannot be sure whether the medicine caused improvement, but if the group given the medicine is healed while the group given the placebo remains ill, researchers can conclude that the medicine causes the illness to go away.

In medical experiments, which group receives placebos?

the experimental group

the control group

both the experimental and control groups

neither the experimental nor control group

Explanation:

5 0
3 years ago
It's important to understand that even information systems that do not use computers
Delvig [45]

Answer:

yes I am not sure if you have any questions or concerns please visit the plug-in settings to determine how attachments are handled the situation in the measurements of the season my dear friend I am not sure if you can send you a great day to day basis of

6 0
3 years ago
Other questions:
  • Write a unit test for addInventory(). Call redSweater.addInventory() with parameter sweaterShipment. Print the shown error if th
    9·2 answers
  • Building relationships during your career exploration is called
    9·2 answers
  • Sam's manager would like him to create and distribute copies of a budget report for each department. The budget report should sh
    10·2 answers
  • ETC = 220,000 PV = 25,000 AC = 40,000. What is EAC? What does this calculation tell you?
    5·1 answer
  • Which one of the following analog VOM ranges would be selected to measure a DC
    13·1 answer
  • Write a program that declares an array named myArray with 8 components of the type int. Initialize the array to 8 values that th
    6·1 answer
  • Match the protocols to their use. HTTP POP3 SMTP FTP You check email in your inbox. arrowRight You send an email to a friend. ar
    14·1 answer
  • create a function that draws a certain number of spaces, followed by a certain number of stars, followed by a newline.
    6·1 answer
  • _____ is the practice of using the internet to provide healthcare without going to a doctor’s office or hospital.
    15·2 answers
  • Which data type is used to teach a Machine Learning (ML) algorithm during structured learning?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!