954,499 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

C++ help not sure where to start

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

eforry
Newbie Poster
2 posts since Mar 2009
Reputation Points: 10
Solved Threads: 0
 

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

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

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)

tux4life
Nearly a Posting Maven
2,350 posts since Feb 2009
Reputation Points: 2,134
Solved Threads: 243
 
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;

 }
}
eforry
Newbie Poster
2 posts since Mar 2009
Reputation Points: 10
Solved Threads: 0
 

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 anif statement then just delete line 9.

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

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> )
tux4life
Nearly a Posting Maven
2,350 posts since Feb 2009
Reputation Points: 2,134
Solved Threads: 243
 
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

smart7
Newbie Poster
2 posts since Apr 2009
Reputation Points: 10
Solved Threads: 0
 
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 ...

tux4life
Nearly a Posting Maven
2,350 posts since Feb 2009
Reputation Points: 2,134
Solved Threads: 243
 
need help with ac++ problem

We are not mind readers!

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

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
To: [email]borborsmart508@aol.com[/email]
Sent: Wed, 1 Apr 2009 7:38 am
Subject: Reply to post 'C++ help not sure where to start'

smart7
Newbie Poster
2 posts since Apr 2009
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You