13. Write a program that reads in an integer that is greater than 1,000 and less
ID: 3638742 • Letter: 1
Question
13. Write a program that reads in an integer that is greater than 1,000 and
less than 1,000,000. Recall that the number must be entered without a
comma. Display the number with a comma inserted where it belongs.
(Hint: use the % operator.)
15. Write a program that dispenses change. The program should read the
amount of the purchase and the amount paid and then display the number of dollars, quarters, dimes, nickels, and pennies given in change. (Hint: Convert the purchase amount and the amount paid to pennies.) Calculate the difference (changeDue). Use the % operator to determine how many dollars to pay. Subtract that number of pennies from changeDue and continue this process for quarters, dimes, etc.
Your answer may be off by a penny. Do you have any idea why this
might be the case? How could you correct this?
18 Hospitals use programmable pumps to deliver medications and
fluids to intravenous lines at a set number of milliliters per hour.
write a program to output information for the labels the hospital
pharmacy places on bags of I.v. medications indicating the volume of
medication to be infused and the rate at which the pump should be
set.The program should prompt the user to enter the quantity of
fluid in the bag and the number of minutes over which it should be
infused. Output the VTBI (volume to be infused) in ml and the infusion
rate in ml/hr.
Explanation / Answer
please rate - thanks
#include <iostream>
using namespace std;
int main()
{double cost, paid;
int change,n;
cout<<"Enter the cost of the purchase: ";
cin>>cost;
cout<<"Enter amount paid: ";
cin>>paid;
change=(paid-cost)*100;
cout<<"Your change is: ";
n=change/100;
cout<<n<<" dollars ";
change%=100;
n=change/25;
cout<<n<<" quarters ";
change%=25;
n=change/10;
cout<<n<<" dimes ";
change%=10;
n=change/5;
cout<<n<<" nickles ";
change%=5;
cout<<change<<" pennies ";
system("pause");
return 0;
}
see my previous answer to you as to why the penny off
-----------------------
#include <iostream>
using namespace std;
int main()
{double fluid, rate,vtbi,inf;
cout<<"Enter the amount of fluid in the bag: ";
cin>>fluid;
cout<<"Enter the number of minutes over which it should be infused: ";
cin>>rate;
inf=60./rate;
vtbi=fluid/inf;
cout<<"VTBI="<<vtbi<<" ml, infusion rate="<<inf<<" ml/hr ";
system("pause");
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.