Today we went over some practice problems for ACSL. Some struggled a bit to find the solution to the problems.
The answer to this problem which we went over in class is something like this: (in c++) dist = [450, 140, 120, 320,250, 80]; double mpg = 25, gp = 3.79, mph = 50; //read position 1 and position 2
char a, b;
cin>>a>>b;
// get indices in array int p1 = a-'A'; int p2 = b-'A';
//iterate through the path to get full distance int distance = 0; for(int i = p1;i<p2;i++){ distance+=dist[i]; }
// print answer distance; // distance distance/mph; //time in hours( not fully accurate, take out decimal and multiply by 60 to get minutes then format accordingly) distance/mpg * gp; // price in dollars
Your HW for next class