Write a program that accepts length measurements from the user, and also whether the length is in inches, feet or meters (use the following screen shots as a guide). Keep track of the total length in meters and report the total after each user entry as shown below. When the user decides to stop entering information, display the message "Goodbye!" as shown. You will need to know the following conversion: 1 meter = 3.2808 feet.

Ive started creating a loop but it keeps giving errors I was wondering if any body would know how to write this program

Recommended Answers

All 9 Replies

You will have to post the code you started because my eyesight isn't good enough to see your monitor.

Yeah, we aren't writing programs for you, you first have to show some effort, post the code you already have ...

And if you don't know where to start then do the following: break the problem down into little parts which are simple to solve, then you put everything together and the big problem is solved ...
(this process is also known as abstraction)

char op;
 double total = 0;
 double num;


do
 {
		
	 if (
	 cout << "Please enter a length: ";
		cin >> num;
		cout << endl;
		cout << "<I>nches, <F>eet or <M>eters?" ;
		cin >> op;
		cout << endl;
	
		if (op == 'M')
		{
			total = num ;
			
		}
		if (op == 'F')
		{
			total = (num / 3.2808) ;
		}
		if (op == 'I')
		{
			total = ((num / 12) / 3.2808);
		}
	
	cout << " The current total length is " << num << " meter." << endl;

 }
}

1) There is no function

#include <iostream>
using namespace std;
int main()
{
   // your code here
}

2) Line 9 is an incomplete if statement. if( <some condition goes here> ) { . If you don't want an if statement then just delete line 9.

Hasn't there to be a 'while' after the '}' on line 33 ?
I don't know any C++ statement with only 'do', it think you meant the 'do while' ...

e.g.:

do
{
    /* Your code here */
} while ( <condition> )

You will have to post the code you started because my eyesight isn't good enough to see your monitor.

need help with ac++ problem

need help with a c++ problem

I think that was logic, but what's 'a' problem, we have to know what problem ...

In this case he has problems with some existing code ...

need help with ac++ problem

We are not mind readers!

Hello sir,


Please write me a C++ program that will calculate how many miles per gallon a car gets. I want my odo meter reading at a certain point when my tank is full and then the next time I fill my tank.please note the current odometer reading and how many gallons I added. Please use functions for input and output and to determine the miles per gallon. Also let one function pass variable by refrence and use preconditions and postconditions in the function definitions.

-----Original Message-----
From: DaniWeb IT Discussion Community <community@daniweb.com>
To: borborsmart508@aol.com
Sent: Wed, 1 Apr 2009 7:38 am
Subject: Reply to post 'C++ help not sure where to start'

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.