0

Transportation Problems Case 1 and 2

So I've done both of these problems, but everytime I completed one of them, it gave me an error. For example, if I do the first problem, it says that is correct, than I do the second and it says that the first one in wrong....What can I do to have both of them right? Please help me. Thanks to everyone who will help me.

27th May 2021, 8:47 PM
Davide Lamuraglia
Davide Lamuraglia - avatar
7 Answers
+ 1
surely find the correct (generic) algorithm ;P
27th May 2021, 8:52 PM
visph
visph - avatar
+ 1
oh, and don't expect for someone to give you the code without trying to doing by yourself first: we are not code providers, and if you do courses it's normally that you want to learn/practice ;) however, feel free to request for more help :)
27th May 2021, 9:35 PM
visph
visph - avatar
0
@visph I'v done both of them correctly, but when I do the second, it says that the first one is wrong. Can you help me?
27th May 2021, 8:57 PM
Davide Lamuraglia
Davide Lamuraglia - avatar
0
maybe... share your attempt(s), so I or others will be able to guide you ;)
27th May 2021, 9:02 PM
visph
visph - avatar
0
@visph I know that it isn't a great program, but I tried to do my best, I want to improve myself everyday. I will listen to any advice. Anyway, thanks. Case 1 #include <iostream> using namespace std; int main() { //your code goes here int a=12;//input int b=26; int c=a-b;//output cout <<c; return 0; } Case 2 #include <iostream> using namespace std; int main() { //your code goes here int a=231;//input int b=50;// n of passengers int c=a-b; int d=c-b; int e=d-b; int f=e-b; int g=b-f;//output cout << g; return 0; }
27th May 2021, 9:15 PM
Davide Lamuraglia
Davide Lamuraglia - avatar
0
at first you don't have to hardcode the input, but read it from user: if you read the lesson(s) again, you should have learned how to do input and output... anyway, to save a few your time, 'cin' is used to get input (Console INput), and 'cout' to print somethingd to screen (Console OUTput) ^^ so, you store input in a previously declared 'int' variable, that you could use to compute the result to be outputed with the generic formula for your problem...
27th May 2021, 9:22 PM
visph
visph - avatar
0
as alternative, you may use loop to compute the result but despite a few less efficiency, you will learn that in the next lessons module...
27th May 2021, 9:28 PM
visph
visph - avatar