The manager of the Telemarketing Group has asked you to write a program that will help order- entry operators look up product prices. The program should prompt the user to enter a product number, and will then display the title, description, and price of the product. The program will consist of the following functions.
getProdNum: it asks the user to enter a product number. Please be sure to reject any value out of the range of correct product numbers.
C++
binarySearch: to search an array for a product.
displayProd: to display the title, and the price of the product.
design a class to do the previous job and please submit a compressed folder with(header file, implementation, main program, and screenshot of the results.)
Code according to given instructions.
--------------------------------
product.h
-----------------------------------
#include <string>
using namespace std;
class product{
private:
string title,description;
int id;
float price;
public:
product();
product(int id,string title,string description,float price);
void setID(int id);
void setTitle(string title);
void setDescription(string description);
void setPrice(float price);
int getID();
string getTitle();
string getDescription();
float getPrice();
void displayProd();
};
----------------------------------
product.cpp
----------------------------------------
#include <iostream>
#include <string>
#include "product.h"
using namespace std;
product::product(){
}
product::product(int id,string title,string description,float price){
this->id=id;
this->title=title;
this->description=description;
this->price=price;
}
void product::setID(int id){
this->id=id;
}
void product::setTitle(string title){
this->title=title;
}
void product::setDescription(string description){
this->description=description;
}
void product::setPrice(float price){
this->price=price;
}
int product::getID(){
return this->id;
}
string product::getTitle(){
return this->title;
}
string product::getDescription(){
return this->description;
}
float product::getPrice(){
return this->price;
}
void product::displayProd(){
cout<<"Title:"<<this->title<<"\nDescription: "<<this->description<<"\nPrice: "<<this->price<<endl;
}
--------------------------
main.cpp
----------------------------
#include <iostream>
using namespace std;
#include "product.h"
int binarySearch(product arr[], int start, int end, int id)
{
if (end >= start)
{
int middle = start + (end - start)/2;
if (arr[middle].getID() == id) return middle;
if (arr[middle].getID() > id) return binarySearch(arr, start, middle-1, id);
return binarySearch(arr, middle+1, end, id);
}
return -1;
}
void getProdNum(product arr[], int start, int end){
int id;
cout<<"Enter product number: ";
cin>>id;
int index=binarySearch(arr,start,end, id);
if(index==-1){
cout<<"out of range or product found"<<endl;
}
else{
arr[index].displayProd();
}
}
int main() {
int size =5;
product p[5]={product(1,"drink","it is a fizzy drink",10.2),product(2,"bread","its a wheat bread",4.3),product(3,"soda","chill soda",3.1),product(4,"bulb","light",5),product(5,"phone","smart phone",100)};
getProdNum(p,0,size-1);
return 0;
}
---------------------------------------------------
output
-------------------------------------------

IF YOU HAVE ANY QUERY PLEASE COMMENT DOWN BELOW.
PLEASE GIVE A THUMBS UP
----------------------------------------------------
The manager of the Telemarketing Group has asked you to write a program that will help...
The manager of the Telemarketing Group has asked you to write a program that will help order- entry operators look up product prices. The program should prompt the user to enter a product number, and will then display the title, description, and price of the product. The program will consist of the following functions. getProdNum: it asks the user to enter a product number. Please be sure to reject any value out of the range of correct product numbers. binarySearch:...
In Small Basic Write a program that asks the user how many numbers s/he wishes to enter into an array and then enters a loop and proceeds to get those numbers from the user and enter them into the array. Once the array has been filled with the numbers, your program then asks the user to make a choice indicating what s/he wishes to do with the numbers in the array. The choices are: TextWindow.WriteLine("Enter 1 to compute and display...
Please write a Java program that does the following: Create an array of 100 integers. Store 100 random integers (between 1 and 100) in the array. Print out the elements of the array. Sort the array in ascending order. Print out the sorted array. Prompt the user to enter a number between 1 and 100. Search the array for that number and then display "Found" or "Not Found" message. Display each number from 1 to 100 and the number of...
Complete the implementation of the point_3d program. This program will help you learn how to use: the C language if statement; relational operators; and boolean operators. The program must implement a function which maps real-valued point (x,y) to real value z≥0, as follows: z=2.84898x+1.18569y, when x≥0 and y≥0; z=2.84898x+y2, when x≥0 and y<0; z=x2+1.18569y, when x<0 and y≥0; z=x2+y2, otherwise. To get the values of x and y, display a prompt of the form "Please enter X and Y:" The...
With your partner, brainstorm a program that will ask the user for a number of digits to be stored. The program should then create an array of that size and then prompt the user for numbers to fill each position in the array. When all of the positions are filled, display the contents of the array to the user. Create a new Project named FillArray and a new class in the default packaged named FillArray.java. You and your partner should...
In C++ 1. Write a program that allows a user to enter 10 integer values from the keyboard. The values should be stored in an array. 2. The program should then ask the user for a number to search for in the array: The program should use a binary search to determine if the number exists in a list of values that are stored in an array (from Step #1). If the user enters a number that is in the...
(C programing, Not C++) Write a program in C that asks the user to input 10 numbers. Store these numbers in an array. Then ask the user to input a single number. Your program should execute a linear search on the array, trying to find that number. If the number exists in the array, have the program print out which position/element the number was found at. If the target number is not in the array, have the program print out...
Program is to be written In C++, The output should look like the
screen shot. It should allow the user to continue to ask the user
to enter all employee ID's until done and then prompt the user to
enter the hours and pay rate for each employee ID. Please help:(
Can you please run the program to make sure the output is just like
the screenshot please? It needs to have the output that is in the
screenshot provided,...
in C++ please
ELET 2300 Programming Assignment # 2 Write a program that generates an array filled up with random positive integer number ranging from 15 to 20, and display it on the screen. After the creation and displaying of the array, the program displays the following: [P]osition [Reverse, [A]verage, (Search, [Q]uit Please select an option: Then, if the user selects: -P (lowercase or uppercase): the program displays the array elements position and value pairs for all member elements of...
Program in C++! Thank you in advance! Write a menu based program implementing the following functions: (1) Write a function that prompts the user for the name of a file to output as a text file that will hold a two dimensional array of the long double data type. Have the user specify the number of rows and the number of columns for the two dimensional array. Have the user enter the values for each row and column element in...