Train A, traveling 70 miles per hour (mph), leaves Westford heading toward Eastford, 260 miles away. At the same time Train B, traveling 60 mph, leaves Eastford heading toward Westford. When do the two trains meet? How far from each city do they meet?
#include <cstdio>
#define EASTFORD 260
int main() {
int trainA=0,trainB=EASTFORD,hours=0;
while(trainA!=trainB){
trainA+=70;
trainB-=60;
hours++;
}
printf("They meet after %d hours.\n",hours);
printf("Train A will be %dmi away from Westford, and %dmi on the way to Eastford,\n",trainA,EASTFORD-trainA);
printf("Train B will be %dmi away from Eastford, and %dmi to Westford.\n",EASTFORD-trainB,trainB);
return 0;
}
Haha, right, so I'll ask seriel if she can fix solution (modify) using only integer variables. In case when train B traveling with 65mph and if you can't change "while" condition.
#include <cstdio>
#define EASTFORD 260
int main() {
int trainA=0,trainB=EASTFORD,seconds=0;
int vA = 70;
int vB = 65;
while(trainA!=trainB){
seconds = trainB * 3600 / (vA + vB);
trainA = trainB = vA * seconds / 3600;
}
printf("They meet after %d hours %d minutes and %d seconds.\n",seconds/3600,seconds/60%60,seconds%60);
printf("Train A will be %dmi away from Westford, and %dmi on the way to Eastford,\n",trainA,EASTFORD-trainA);
printf("Train B will be %dmi away from Eastford, and %dmi to Westford.\n",EASTFORD-trainA,trainA);
return 0;
}
guys i just checked to see what's in the fortnite item shop today and saw that metallica skins, atla skins and jjk skins are in the item shop at the same time rn, shit's not real
Btw it seems like the user dtapple disabled others posting on their profile, either they are going through something or they blocked me. Better leave them alone ig