Hi, complete beginner here. In need for some help with the assignment.
So for the first part we had to write a program that:
1. reads three values (velocity, time and length), and after entering them it prints them on screen. (done)
2. calculates the remaining path to the goal. (done)
3. tells if the goal is already passed or not(done)
Code until here:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
#include <iostream>
using namespace std;
int main () {
int velocity;
cout << "Velocity value: ";
cin >> velocity;
int time;
cout << "Time value: ";
cin >> time;
int length;
cout << "Length value: ";
cin >> length;
cout << velocity << " " << time << " " << length << endl;
int RemainingPath = length - time * velocity;
cout << RemainingPath << endl;
if (RemainingPath < 0) {
cout << "passed the goal" << endl;
}
else {
cout << "didn't pass the goal" << endl;
}
return 0;
}
|
So the second part is where I got stuck.
We have to draw out the progress. With the symbol "*" the number of percentage by which a rider has finished the track, and with "." for unfinished part of the track. Then write the percentage of distance traveled.
I kinda just need some tips on how to get started.
Wrote out something like this, but don't know how to put it all together:
1 2 3 4 5 6 7 8 9 10 11 12 13
|
for(int i =0;i<100;i++)
{
if(i<percent)
{
cout<<"*";
}
else
{
cout<<".";
}
}
cout<<endl;
|
Would really appriciate any help I can get.
And sorry for my broken English, it's not my first language. :)