/* BB-8 distance traversal * BB-8 has to travel 2.5 miles. * Given, BB-8's diameter is 1.5 feet, calculate the nuber of times, BB-8 has to roll to cover the distance. * * Idea: Number of rolls = distance / circumference */ #include #include using namespace std; int main() { double diameter = 1.5, distance = 2.5; double circ = 3.14 * diameter; //Pi = 3.14 distance *=5280; //convert miles to feet double numRolls = distance / circ; //We want to print the result in fixed notation (not scientific). //We want the decimal point to show, even if the result is a whole nu,ber. //We want to print the result accurate to 3 decimal places. cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(3); cout<<"BB - 8 rolls "<