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
Wich is the correct process for selecting an entire row in a spreadsheet?
umka21 [38]
CTRL - (select sentence) - ALT

4 0
3 years ago
Special keys that allow you to use the computer to perform specific functions
Pavel [41]

Answer:

Examples are Ctrl, Alt, Fn, Alt Gr, Shift, Caps Lock, Tab, Scroll Lock, Num lock, Esc, Windows Key, Backspace, Enter...

8 0
3 years ago
Write a program that reads numbers from the user until a blank line is entered. Your
ddd [48]

Answer:

nums = []

while True:

   in = input()

   if in:

       nums.append(in)

   else:

       break

if nums:

   avg = sum(nums) / len(nums)

   for i in range(len(nums)):

       if nums[i] == avg:

           print(f"index: {i+1}")

           print(nums[i])

else:

   print(-1)  # if there aren't any values in nums

Explanation:

Assuming that you are coding in Python 3x. The last 'else' statement is an edge case that you might want to consider, I don't know what you want to put there, but I'm just going to leave it as -1.

5 0
3 years ago
Which of the following is not a type of bank? A.Credit Union B.Online Bank C.Payday Lender D.Retail Bank
Damm [24]
C. a payday lender is a type of loan
7 0
3 years ago
If your cpu usage levels are greater than ___________% during most of your work session, a faster CPU can greatly increase your
motikmotik

Answer:

If your cpu usage levels are greater than 90% during most of your work session, a faster CPU can greatly increase your computer's performance

Explanation:

CPU usage level is a good indicator for the computer performance.

Generally, computers use a low portion of their CPU power. When you open an application or listen to music on your computer, CPU usage level increases. After CPU intensive process ends, the CPU usage should drop to lower level again.

But if the CPU usage level is high all the time you use the computer, then it means that either there is a problem causing continuous CPU usage or your CPU is not fast enough. In the case of latter, you'd better to have a faster CPU.

6 0
3 years ago
Other questions:
  • A type TW cable containing two No. 12 copper conductors has a maximum overcurrent protection of
    7·2 answers
  • What makes an active heat sink different from a passive heat sink?
    12·1 answer
  • Shania has started a new job as an app developer. Her first task was to make an old app designed for Android available on other
    6·1 answer
  • Amazon Web Services (AWS): Group of answer choices a) forms a majority percentage of Amazon's overall revenue. b) was introduced
    15·1 answer
  • The ___________________ Act makes it illegal to deactivate or otherwise disable any antipiracy technologies including DRM techno
    7·1 answer
  • You are a database administrator. Chantelle comes to you asking for help on how to access all the data in one row of the databas
    11·1 answer
  • Mha lovers why do other anime lovers report mha lovers for not liking there anime?
    6·2 answers
  • Barbara, an employee, has properly connected her personal wireless router to a network jack inside her office. The router is una
    7·1 answer
  • In your opinion, who is the best Mine.Craft player overall?
    10·2 answers
  • Use a while loop to output the even number from 100 to 147? This is python
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!