NEED HELP

i need to make a program that relates to fair metrics please help me im newbie in programs


Discription: it will find the total amount of fair of the passenger in 1 kilometer

input: compute the fair of the passenger

Output: total of the kilometers fair

results: how much the fair of the passenger in one kilometer..
Hey there bud, by the way this is my first ever answer.. woohoo!

Anyways,

It's good practice to be very specific when you write your question on any kind of forum (that's right, it need not even be a programming forum! We might not always interpret your question or your needs correctly if you're not specific.

I'll assume that:
1) input involves taking total cost paid by the passenger, kilometers traveled.
2) cost per kilometer is calculated by: total cost/kilometers.

so we can write a simple console program for this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include<iostream.h>
int main(){
    int kilometres, total_cost, cost;

    std::cout<< "How many Kilometers has the passenger traveled?\n";
    std::cin>> kilometres;
    std::cout<< "\nHow much was the total fair?\n";
    std::cin>> total_cost;

    std::cout<< \n\nIt costed you " << total_cost/kilometres << " per kilometer!";

    std::cin.get();
    std::cin.get();
} 


~*Learning programmer*


Last edited on
the passenger cost will be 8 and every 1 kilometer traveled is 2 that would be the computation....


anyway thank you so much ^_^
why is it not running?
Why is what not running?
Last edited on
that program it is not running in my dev c++ application why is that i tried so many times
First line should be
#include <iostream>

It is missing the first quote " before \n\nIt costed you" [sic]. Correcting the grammar at the same time, try
std::cout<< "\n\nIt cost " << total_cost/kilometres << " per kilometer!";
(On pedantic grounds, "fair" should be "fare" here, as well.)

You will suffer integer division problems unless variables kilometres, total_cost and cost are of type double, rather than int.
Last edited on
it is not running in my dev c++ application

My point was that you haven't shown us your code.

Also, you haven't given us a helpful description of the problem.

Is your code compiling?

Are you getting error messages when you compile it?

If it is compiling, what happens when you try and run it? Are you getting any error messages when you try and run it?

Be specific. The more information you give us, the more we can help you.
Topic archived. No new replies allowed.