You need to design a program for a pharmacy. The program must work on an ever changing price list that the pharmacy needs to keep track of. The user must be able to enter the number of different thermometers that they receive in a week. Then the user should be prompted for a price list on those thermometers. There are two versions of this program required.
//pharmvector.cpp
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n;
cout<<"enter number of
thermometers:"<<endl;
cin>>n;//taking input of number of
thermometers
vector<int>v(n);//declaring vector v to take
inputs
vector<int>ascending(v);//declaring vector
ascending to store the ascended values
vector<int>descending(v);// declaring vector
descending to store the descended values
cout<<"enter the prices of
thermometer:"<<endl;
int i,j;
//taking inputs
for( i=0;i<n;i++)
{
cin>>v[i];//taking input in v[i]
ascending[i]=v[i];//copying into ascending[i]
descending[i]=v[i];//copying into descending[i]
}
// we are writing both ascending and descending bubble
sort at once so that it will be fast
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
// for ascending if the present value is greater than
the one with we are comparing, swap
if(ascending[i]>ascending[j])
swap(ascending[i],ascending[j]);
// for descending if the present value is lesser than
the one with we are comparing swap
if(descending[i]<descending[j])
swap(descending[i],descending[j]);
}
}
cout<<"in ascending order:"<<endl;
//printing ascending list
for( i=0;i<n;i++)
{
cout<<ascending[i]<<" ";
}
cout<<endl;
cout<<"in descending order:"<<endl;
//printing descending list
for( i=0;i<n;i++)
{
cout<<descending[i]<<" ";
}
cout<<endl;
float median;
//if the list is even the median is average of the two
middle elements
//we are type casting with float because some times
the median may be in floating points
if(n%2==0)
median=((float)ascending[n/2]+(float)ascending[n/2-1])/2;
//else the median is the middle element
else median=ascending[n/2];
cout<<"median:"<<median<<endl;
return 0;
}



#include <iostream>
using namespace std;
int main() {
int n;
cout<<"enter number of
thermometers:"<<endl;
cin>>n;//taking input of number of
thermometers
int v[n];//declaring vector v to take inputs
int ascending[n];//declaring vector ascending to store
the ascended values
int descending[n];// declaring vector descending to
store the descended values
cout<<"enter the prices of
thermometer:"<<endl;
int i,j;
//taking inputs
for( i=0;i<n;i++)
{
cin>>*(v+i);//taking input in v[i]
*(ascending+i)=*(v+i);//copying into
ascending[i]
*(descending+i)=*(v+i);//copying into
descending[i]
}
// we are writing both ascending and descending bubble
sort at once so that it will be fast
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
// for ascending if the present value is greater than
the one with we are comparing, swap
if(*(ascending+i)>*(ascending+j))
swap(*(ascending+i),*(ascending+j));
// for descending if the present value is lesser than
the one with we are comparing swap
if(*(descending+i)<*(descending+j))
swap(*(descending+i),*(descending+j));
}
}
cout<<"in ascending order:"<<endl;
//printing ascending list
for( i=0;i<n;i++)
{
cout<<*(ascending+i)<<" ";
}
cout<<endl;
cout<<"in descending order:"<<endl;
//printing descending list
for( i=0;i<n;i++)
{
cout<<*(descending+i)<<" ";
}
cout<<endl;
float median;
//if the list is even the median is average of the two
middle elements
//we are type casting with float because some times
the median may be in floating points
if(n%2==0)
median=((float)*(ascending+n/2)+(float)*(ascending+n/2-1))/2;
//else the median is the middle element
else median=*(ascending+n/2);
cout<<"median:"<<median<<endl;
return 0;
}


if you are satisfied please
upvote or if you have any doubts post them in comment section
Happy learning
You need to design a program for a pharmacy. The program must work on an...
Python 3.7 to be used. Just a simple design a program
that depends on its own. You should also not need to import
anything. No code outside of a function!
Median List Traversal and Exception Handling Create a menu-driven program that will accept a collection of non-negative integers from the keyboard, calculate the mean and median values and display those values on the screen. Your menu should have 6 options 50% below 50% above Add a number to the list/array...
Using c++ Write a program that reads in a list of up to 25 first names from an input file nameData.txt and allows the user to display the name data, sort it in ascending or descending order, count the number of occurrences of a given name, or exit the program. The input file consists of a single names per line with each line terminated with an end of line (i.e. using Enter key to end the line). Your program should...
in JAVA program.Use top-down design to design and implement a program to ask the user to enter a list of integers, and then display to the user the mean and median of this list. You should first prompt the user to specify the length of the list of integers. For this assignment, your code should create an array of size 10, and then allow the user to specify the number of integers in their list, up to a maximum of...
Homework IX-a Write a program that opens a text file, whose name you enter at the keyboard You will be using the file text.txt to test your program. Print out all of the individual, unique words contained in the file, in alphabetical order Print out the number of unique words appearing in text.txt. Call your program: YourName-HwrklXa.py Make sure that your name appears as a comment at the beginning of the program as well as on the output display showing...
Using C++ create a lotto program Lottery Design a program that simulates a lottery. Requirements: The program should have an array of 5 integers named lottery and should generate a random number in the range of 1 through 99 for each element of the array. The user should enter five digits, which should be stored in an integer array named user. The program is to compare the corresponding elements in the two arrays and keep a count of the digits that...
Please program this in Visual Basic 6.
You have chosen to create an electronic version of the sliding tile puzzle game. The object of the game is to slide the tiles so that they end up in the required order. The images shown below are examples of the two different versions of this puzzle (numeric and graphical) Puzzle Board-Numeric Puzzle Board-Graphical File Options Help Elapsed Time File Options Help Elapsed Time 00:02:12 00:04:20 5 6 7 8 9 10 11...
This application is for you, the shopper in mind. Putting together an itemized shopping list that contains the items you need, the items you want, and the anticipated cost, this program will generate a total price. This way you can decide if your shopping budget fits the bill. Example list: Price List Binder paper: 2.29 Mop: 7.50 Scouring pads: 5 Your application program will create and write a new list to an output file in which the need and wish...
(C++ Program) 1. Write a program to allow user enter an array of structures, with each structure containing the firstname, lastname and the written test score of a driver. - Your program should use a DYNAMIC array to make sure user has enough storage to enter the data. - Once all the data being entered, you need to design a function to sort the data in descending order based on the test score. - Another function should be designed to...
A set of data (test scores), can be summarized by a frequency distribution chart. For example, if the list of test scores is: 90 85 100 50 50 85 60 70 55 55 80 95 70 60 95 80 100 75 70 95 90 90 70 95 50 65 85 95 100 65 then the frequency distribution chart looks like the one below: value frequency ------ ------------ 100 3 95 ...
This program will reinforce our knowledge on basic ‘C’ program control, arrays, and editing and compiling ‘C’ programs. The objective of this assignment is to create a program that tallies a shopping list of items and displays each selected item, item cost, and total cost of all the selected items plus tax. The program will setup a simple sporting goods store with a few items and prices. The user will submit a shopping list in a textfile and submit it...