The document contains instructions for 3 programming problems that are due on October 12, 2015 for a Computer Programming Language course. Problem 1 involves writing a program to calculate taxi fare based on miles travelled. Problem 2 involves writing a program to convert US dollars to British pounds sterling based on the currency conversion rate. Problem 3 involves writing a program to output the equation of the perpendicular bisector of a line segment between two input points.
2. Problem 1.
▪ Write a program that calculates taxi fare at a rate of $1.5 per mile. Your
program should interact with the user in this manner:
▪ Taxi Fare calculator
▪ Enter the distance travelled in miles: 20.2
▪ Your fare is $30.3.
▪ (執行:利用學號倒數第三碼為十位數字;倒數第二碼為個位數字;倒數第一碼為小數點
後第一位數字,將指令視窗進行截圖,與程式碼放置於相同檔案夾。)
台北科技大學104年第一學期計算機程式語言
3. Problem 2.
▪ Write a program to convert a currency in US dollars (美元) to pounds sterling
(英鎊).
▪ Problem Input : float dollar; /* Currency in US dollars */
▪ Problem Output : float pounds; /* Currency in pounds sterling */
▪ Relevant Formula : 1 USD($) = 0.636 pounds sterling (£).
▪ (執行:利用學號倒數第三碼為美元。執行完畢後,將指令視窗進行截圖,與程式碼放置
於相同檔案夾。)
台北科技大學104年第一學期計算機程式語言
4. Problem 3.
▪ Write a program that outputs the equation of the perpendicular bisector of
the line segment between two points. Your program should
▪ prompt for and input the coordinates of the two points
▪ [for example, try the points (2.0, −4.0) and (7.0, −2.0)];
▪ compute the slope of the line between those two points;
▪ compute the coordinates of the midpoint of the line segment between the
two points by averaging the two x coordinates and the two y coordinates;
台北科技大學104年第一學期計算機程式語言
5. Problem 3.(Cont.)
▪ compute the slope of the perpendicular bisector by taking the negative
reciprocal of theslope of the line segment;
▪ compute the y intercept of the perpendicular bisector
▪ (you now have the slope m of the bisector and a point ( xmid , ymid ) on the
bisector, so the y intercept is ymid − m xmid );
▪ output with labels the original two points, and output in y = mx + b format
the equation of the perpendicular bisector. Figure 2.19 illustrates the sample
line segment mentioned above and its perpendicular bisector.
台北科技大學104年第一學期計算機程式語言
6. Problem 3.(Cont.)
▪ Test your program to be sure it works on different pairs of points. However,
there will be some pairs of points for which you can’t make your program
work (at least not at this stage).
▪ Think about what points will cause your program to fail, and write a
paragraph describing which points fall in this category.
台北科技大學104年第一學期計算機程式語言