Keeping track of how much medicine you need to take could be a hassle. It would be even harder to keep
track if you need to change the dosage based on what time in the day you need to take it. Some medicine
is recommended to take more in the beginning and less for every hour. Your task is to create a program
that can handle the
following type of dosage:
1. Constant dosage, where the total amount is divided by the amount of hours
Functional requirements:
Your program will ask for total amount of medicine and total amount of hours that the dosage must be
calculated for. Your calculations should only give the dosage in full integers (since we cannot split up
the medicine pills). Higher dose is given first.
Non
-functional requirements:
1. Your solution must be readable
2. Your solution must be well structured and have good abstraction
3. Your solution must match the example below exactly
#include<iostream>
using namespace std;
int main(){
int medicine,hours,doeses,numMedi,numCheck;
cout<<"Welcome to dose track!"<<endl;
cout<<"Please enter the amount of medicine:"<<endl;
cin>>medicine;
cout<<"over how many hour would you take the medicine:"<<endl;
cin>>hours;
cout<<"What is the total amount of medicine (in gram)? :"<<medicine<<endl;
cout<<"Over how many hours do you want to take the medicine 6?"<<hours<<endl;
cout<<"The dosage is:"<<endl;
numMedi=(medicine/hours);
numCheck=numMedi;
for(int i=0;i<numMedi;i++){
//numCheck+=numMedi;
if(medicine>=numCheck){
if(i>numMedi/2){
cout<<(numMedi-1)<<endl;
}else{
cout<<numMedi<<endl;
}
cout<<","<<endl;
}
}
return 0;
}
Comments
Leave a comment