In: Computer Science
Using C++ code, write a program named q3.cpp to compute the total amount of medicine m absorbed by a rabbit, where the rabbit gets 2 pills containing n1 and n2 grams of medicine, respectively, of which the rabbit absorbs 60% and 35%, respectively, and n1 and n2 are input by a user via the keyboard.
Since, the rabbit gets 2 pills containing n1 and n2 grams of
medicine. The rabbit absorbs 60% and 35%, respectively.
The total amount of medicine absorbed:
m = n1 * 0.6 + n2 * 0.35
Please look at my code and in case of indentation issues check the screenshots.
--------------q3.cpp-----------------
#include <iostream>
using namespace std;
int main()
{
float n1, n2;
//declare
n1, n2 as floats
cout << "Enter n1(grams): ";
cin >> n1;
//read n1, n2 from the user
cout << "Enter n2(grams): ";
cin >> n2;
float m = n1 * 0.6 + n2 * 0.35;
//compute m using 60% of n1, 35% of n2
cout << "\nThe total amount of medicine absorbed
by the rabbit , m = " << m << " grams" <<
endl;
return 0;
}
--------------Screenshots-------------------
----------------------Output------------------------------------
----------------------------------------------------------------------------------------------------------
Please give a thumbs up if you find this answer helpful.
If it doesn't help, please comment before giving a thumbs
down.
Please Do comment if you need any clarification.
I will surely help you.
Thankyou