Help writing this program

Hi, I'm new to C++ programming and due to personal reason I missed class. I'm not sure how to approach this so I ask for help here. Don't get me wrong, I don't want someone to tell me the answer. I just want someone to help me get started. I have basic understanding of using functions and integers, this is just so confusing for me. Maybe I'm just thinking too hard. For this problem we have to use int and double

Problem:

http://i62.tinypic.com/t8460k.jpg
Last edited on
That is a "doublepost" of your earlier thread: http://www.cplusplus.com/forum/beginner/144876/

PS. Deleting contents of post(s) later is not polite.
closed account (48T7M4Gy)
1
2
3
4
#include ...
...
return ...
}
@keskiverto Sorry, I grabbed the wrong one. I've now updated the post.
Have you written any code yet? If not I think you ought to try :) Then please post what you have come up with and then I would be glad to help :)
I have written simple code I just don't know how to go about setting this up.
Well the problem for me is the formulas... which are confusing as hell but if you can convert them into c++ style then it should be easy
I had no issues writing the program below, the one that confused me was the one that im seeking help for now.

/*
This app computes the cost of transporting gallanide
to a colony in the current galactic sector.
*/

#include <iostream>
using namespace std;

int main() {

double DISTANCE_TO_PLANET = 500; // Light-Years
double pricePerKilogram = 25; // Credits per kilogram of gallanide
double kilogramPerLighyear = 12.5; // Kilograms per Light-Years

cout << "How many light-years to the colony's planet? ";
cin >> DISTANCE_TO_PLANET;
cout << "What is the price per kilogram of gallanide? ";
cin >> pricePerKilogram;
cout << "How many kilograms per light-year are used by the transport freighter? ";
cin >> kilogramPerLighyear;

double costPerLightYear = pricePerKilogram / kilogramPerLighyear;
double totalCost = DISTANCE_TO_PLANET * costPerLightYear;

cout << "\nThe distance to the planet is " << DISTANCE_TO_PLANET << " light years. " << endl;
cout << "The price of gallanide per Kilogram is " << pricePerKilogram << " credits. " << endl;
cout << "The rate of distance traveled is " << kilogramPerLighyear << " Kg/ly. " << endl;
cout << "Cost per Light-Year: " << costPerLightYear << " credits" << endl;
cout << "Total cost to transport supplies: " << totalCost << " credits" << endl;

system("PAUSE");
return 0;
} // end main
closed account (48T7M4Gy)
There are a lot of ways of solving this problem but the simplest is to set up a number (approx 5 or 6) of arrays which store the various bits of information you are given in the question or the user inputs. Once the system has all the info then it can be processed using the formulas you're give and the results displayed.

The first step is to produce an array of lifeforms and continents. Think of int lifeFormNumber[x], char lifeFormContinent[x] ... x could be 20 or whatever.
Last edited on
I'll try that thanks
Topic archived. No new replies allowed.