Vous êtes sur la page 1sur 3

THE COPPERBELT UNIVERSITY CS250 ASSIGNMENT SOLUTIONS

NAME: BRIGHT LONDA


SIN:18120707
PROGRAMME: BIOINFORMATICS

Question 1

#include <iostream>
#include <string>
using namespace std;

int circurmfrance(double x){


double result;
//formula
result = x * 2.0 * 3.142;
return result;
}
int main()
{
double x;
cout << "Enter the radius of the circle: ";
if (cin >> x){
cout << "The Circurmfrance is : " << circurmfrance(x) << endl;
}
return 0;
}
//End of question 1
Question 2

#include <iostream>
#include <string>
using namespace std;

//Function to do the math.


string midpoint(int x1, int x2, int y1, int y2){
//declaration of variables
int midX, midY;
//The math and conversion to string
midX = (x1 + x2) / 2;
string mX = to_string(midX);
midY = (y1 + y2) / 2;
string mY = to_string(midY);
//Storage in a single string variable through concatenation.
string midall = "(" + mX + " , " + mY + ")";
return midall;
}
int main(){
//declaration of variables
int x1, x2, y1, y2;
//Request for input
cout << "Enter first coordinates (x1, y1): ";
cin >> x1 >> y1;
cout << "Enter second coordinates: (x2, y2): ";
cin >> x2 >> y2;
//Printing to screen by calling the midpoint function.
cout << midpoint( x1, x2, y1, y2);
return 0;
}

//End of Question 2
Question 3

#include <iostream>
#include <string>
using namespace std;

class meal_calculations {
public:
//METHOD 1
double ingested_calories(double numBurr, double numSal, double numMilk){
double burrito_cal = numBurr * 357;
double salad_cal = numSal * 185;
double milkshake_cal = numMilk * 388;
double sum = burrito_cal + salad_cal + milkshake_cal;
return sum;
}
//METHOD 2
double miles_to_run(double numBurr, double numSal, double numMilk){
double burrito_cal = numBurr * 357;
double salad_cal = numSal * 185;
double milkshake_cal = numMilk * 388;
double sum = burrito_cal + salad_cal + milkshake_cal;
double num_miles = sum / 100;
return num_miles;
};
};
int main() {
double numBurr, numSal, numMilk;
cout << "How many burritos, bowls of salad and milkshakes did you consume? ";
cin >> numBurr>> numSal >> numMilk;
meal_calculations injested; //creating object called injested.
cout << "You ingested " << injested.ingested_calories(numBurr, numSal,
numMilk)<< " Calories" << endl;

meal_calculations run; //creation object called run.


cout << "You will have to run " << run.miles_to_run(numBurr, numSal, numMilk)
<< " miles to expand that much energy.";
return 0;
}

//End of Question 3.

Vous aimerez peut-être aussi