Code compiles and runs correctly, just need to have the 'total' keep adding to itself after the do you want to continue question. Right now it clears it everytime after it asks that question (Hopefully that makes sense)

#include <iostream>
using namespace std;
int main()

{
	double length =0;
	char operation;
	double total = 0;
	char answer = 'Y';

do 
{
cout << "Please enter a length: ";
	cin >> length;
cout << "(I)nches, (F)eet or (M)eters? ";
	cin >> operation;

	if (operation == 'M')
		{
		total = length ;
		}

	if (operation == 'F')
		{
		total = (length / 3.2808) ;
		}

	if (operation == 'I')
		{
		total = ((length / 12) * 3.2808);
		}
	
	
	
cout << "The current total length is " << total<< " meters." << endl;
cout << " Do you want to continue (Y/N)? ";
	cin >> answer;
	
}
	while (answer == 'Y');
	cout << "Goodbye!";
}

Recommended Answers

All 2 Replies

put
total += length,
total += length/3.208,
total += ((length / 12) * 3.2808);

in their respective places. Note D += A is shorthand for D = D + A
Dont forget to terminate the statements.

do 
{
   total += total;     //there is
cout << "Please enter a length: ";
	cin >> length;
cout << "(I)nches, (F)eet or (M)eters? ";
	cin >> operation;

	if (operation == 'M')
		{
		total = length ;
		}

	if (operation == 'F')
		{
		total = (length / 3.2808) ;
		}

	if (operation == 'I')
		{
		total = ((length / 12) * 3.2808);
		}
	
	
	
cout << "The current total length is " << total<< " meters." << endl;
cout << " Do you want to continue (Y/N)? ";
	cin >> answer;
	
}
	while (answer == 'Y');
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.