SlideShare a Scribd company logo
1 of 6
HW2
Due:2015/10/12 23:59
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年第一學期計算機程式語言
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年第一學期計算機程式語言
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年第一學期計算機程式語言
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年第一學期計算機程式語言
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年第一學期計算機程式語言

More Related Content

What's hot (9)

Lab 2
Lab 2Lab 2
Lab 2
 
Calculus 45S Slides May 14, 2008
Calculus 45S Slides May 14, 2008Calculus 45S Slides May 14, 2008
Calculus 45S Slides May 14, 2008
 
7 2 Graphing Simple Quadratic Functions
7 2 Graphing Simple Quadratic Functions7 2 Graphing Simple Quadratic Functions
7 2 Graphing Simple Quadratic Functions
 
Bioalgo 2013-08-alignment-3
Bioalgo 2013-08-alignment-3Bioalgo 2013-08-alignment-3
Bioalgo 2013-08-alignment-3
 
25. composite l2ltouchpad
25. composite l2ltouchpad25. composite l2ltouchpad
25. composite l2ltouchpad
 
Maths
MathsMaths
Maths
 
March 4 and 5, 2009
March 4 and 5, 2009March 4 and 5, 2009
March 4 and 5, 2009
 
Py7 3
Py7 3Py7 3
Py7 3
 
Deep learning 1
Deep learning 1Deep learning 1
Deep learning 1
 

Similar to 10401_206296_Hw2

Practice Exercise Set 1
Practice Exercise Set 1Practice Exercise Set 1
Practice Exercise Set 1
rampan
 
C users_mpk7_app_data_local_temp_plugtmp_plugin-week3recursive
C  users_mpk7_app_data_local_temp_plugtmp_plugin-week3recursiveC  users_mpk7_app_data_local_temp_plugtmp_plugin-week3recursive
C users_mpk7_app_data_local_temp_plugtmp_plugin-week3recursive
rokiah64
 
Modelling handout
Modelling handoutModelling handout
Modelling handout
guru1561
 
202003261537530756sanjeev_eco_Linear_Programming.pdf
202003261537530756sanjeev_eco_Linear_Programming.pdf202003261537530756sanjeev_eco_Linear_Programming.pdf
202003261537530756sanjeev_eco_Linear_Programming.pdf
AnshitTanwar
 
Decimal arithmetic in Processors
Decimal arithmetic in ProcessorsDecimal arithmetic in Processors
Decimal arithmetic in Processors
Peeyush Pashine
 

Similar to 10401_206296_Hw2 (16)

Comp 122 lab 3 lab report and source code
Comp 122 lab 3 lab report and source codeComp 122 lab 3 lab report and source code
Comp 122 lab 3 lab report and source code
 
COMP 122 Entire Course NEW
COMP 122 Entire Course NEWCOMP 122 Entire Course NEW
COMP 122 Entire Course NEW
 
P79 mba202
P79 mba202P79 mba202
P79 mba202
 
Practice Exercise Set 1
Practice Exercise Set 1Practice Exercise Set 1
Practice Exercise Set 1
 
Vba and macro creation (using excel)
Vba and macro creation (using excel)Vba and macro creation (using excel)
Vba and macro creation (using excel)
 
Mechanical Engineering Homework Help
Mechanical Engineering Homework HelpMechanical Engineering Homework Help
Mechanical Engineering Homework Help
 
C users_mpk7_app_data_local_temp_plugtmp_plugin-week3recursive
C  users_mpk7_app_data_local_temp_plugtmp_plugin-week3recursiveC  users_mpk7_app_data_local_temp_plugtmp_plugin-week3recursive
C users_mpk7_app_data_local_temp_plugtmp_plugin-week3recursive
 
Modelling handout
Modelling handoutModelling handout
Modelling handout
 
M150 A Fall2010 T01
M150 A Fall2010 T01M150 A Fall2010 T01
M150 A Fall2010 T01
 
WINSEM2016-17_CSE1002_LO_1336_24-JAN-2017_RM003_session 10.pptx
WINSEM2016-17_CSE1002_LO_1336_24-JAN-2017_RM003_session 10.pptxWINSEM2016-17_CSE1002_LO_1336_24-JAN-2017_RM003_session 10.pptx
WINSEM2016-17_CSE1002_LO_1336_24-JAN-2017_RM003_session 10.pptx
 
HSc Computer Science Practical Slip for Class 12
HSc Computer Science Practical Slip for Class 12HSc Computer Science Practical Slip for Class 12
HSc Computer Science Practical Slip for Class 12
 
Pseudocode algorithim flowchart
Pseudocode algorithim flowchartPseudocode algorithim flowchart
Pseudocode algorithim flowchart
 
202003261537530756sanjeev_eco_Linear_Programming.pdf
202003261537530756sanjeev_eco_Linear_Programming.pdf202003261537530756sanjeev_eco_Linear_Programming.pdf
202003261537530756sanjeev_eco_Linear_Programming.pdf
 
Visual Techniques
Visual TechniquesVisual Techniques
Visual Techniques
 
Decimal arithmetic in Processors
Decimal arithmetic in ProcessorsDecimal arithmetic in Processors
Decimal arithmetic in Processors
 
2621008 - C++ 1
2621008 -  C++ 12621008 -  C++ 1
2621008 - C++ 1
 

More from Jessica Hsieh (10)

Hw12#5
Hw12#5Hw12#5
Hw12#5
 
10401_206296_Hw12
10401_206296_Hw1210401_206296_Hw12
10401_206296_Hw12
 
10401_206296_Hw11
10401_206296_Hw1110401_206296_Hw11
10401_206296_Hw11
 
10401_206296_Hw9
10401_206296_Hw910401_206296_Hw9
10401_206296_Hw9
 
10401_206296_Hw8
10401_206296_Hw810401_206296_Hw8
10401_206296_Hw8
 
10401_206296_Hw7
10401_206296_Hw710401_206296_Hw7
10401_206296_Hw7
 
10401_206296_Hw6
10401_206296_Hw610401_206296_Hw6
10401_206296_Hw6
 
10401_206296_Hw4&5
10401_206296_Hw4&510401_206296_Hw4&5
10401_206296_Hw4&5
 
10401_206296_Hw1
10401_206296_Hw110401_206296_Hw1
10401_206296_Hw1
 
Homework7補充教學
Homework7補充教學Homework7補充教學
Homework7補充教學
 

Recently uploaded

Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...
Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...
Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...
drjose256
 
electrical installation and maintenance.
electrical installation and maintenance.electrical installation and maintenance.
electrical installation and maintenance.
benjamincojr
 
Final DBMS Manual (2).pdf final lab manual
Final DBMS Manual (2).pdf final lab manualFinal DBMS Manual (2).pdf final lab manual
Final DBMS Manual (2).pdf final lab manual
BalamuruganV28
 

Recently uploaded (20)

5G and 6G refer to generations of mobile network technology, each representin...
5G and 6G refer to generations of mobile network technology, each representin...5G and 6G refer to generations of mobile network technology, each representin...
5G and 6G refer to generations of mobile network technology, each representin...
 
Insurance management system project report.pdf
Insurance management system project report.pdfInsurance management system project report.pdf
Insurance management system project report.pdf
 
Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...
Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...
Tembisa Central Terminating Pills +27838792658 PHOMOLONG Top Abortion Pills F...
 
Worksharing and 3D Modeling with Revit.pptx
Worksharing and 3D Modeling with Revit.pptxWorksharing and 3D Modeling with Revit.pptx
Worksharing and 3D Modeling with Revit.pptx
 
engineering chemistry power point presentation
engineering chemistry  power point presentationengineering chemistry  power point presentation
engineering chemistry power point presentation
 
Basics of Relay for Engineering Students
Basics of Relay for Engineering StudentsBasics of Relay for Engineering Students
Basics of Relay for Engineering Students
 
CLOUD COMPUTING SERVICES - Cloud Reference Modal
CLOUD COMPUTING SERVICES - Cloud Reference ModalCLOUD COMPUTING SERVICES - Cloud Reference Modal
CLOUD COMPUTING SERVICES - Cloud Reference Modal
 
8th International Conference on Soft Computing, Mathematics and Control (SMC ...
8th International Conference on Soft Computing, Mathematics and Control (SMC ...8th International Conference on Soft Computing, Mathematics and Control (SMC ...
8th International Conference on Soft Computing, Mathematics and Control (SMC ...
 
Interfacing Analog to Digital Data Converters ee3404.pdf
Interfacing Analog to Digital Data Converters ee3404.pdfInterfacing Analog to Digital Data Converters ee3404.pdf
Interfacing Analog to Digital Data Converters ee3404.pdf
 
Developing a smart system for infant incubators using the internet of things ...
Developing a smart system for infant incubators using the internet of things ...Developing a smart system for infant incubators using the internet of things ...
Developing a smart system for infant incubators using the internet of things ...
 
Intro to Design (for Engineers) at Sydney Uni
Intro to Design (for Engineers) at Sydney UniIntro to Design (for Engineers) at Sydney Uni
Intro to Design (for Engineers) at Sydney Uni
 
Software Engineering Practical File Front Pages.pdf
Software Engineering Practical File Front Pages.pdfSoftware Engineering Practical File Front Pages.pdf
Software Engineering Practical File Front Pages.pdf
 
Circuit Breakers for Engineering Students
Circuit Breakers for Engineering StudentsCircuit Breakers for Engineering Students
Circuit Breakers for Engineering Students
 
electrical installation and maintenance.
electrical installation and maintenance.electrical installation and maintenance.
electrical installation and maintenance.
 
Final DBMS Manual (2).pdf final lab manual
Final DBMS Manual (2).pdf final lab manualFinal DBMS Manual (2).pdf final lab manual
Final DBMS Manual (2).pdf final lab manual
 
UNIT 4 PTRP final Convergence in probability.pptx
UNIT 4 PTRP final Convergence in probability.pptxUNIT 4 PTRP final Convergence in probability.pptx
UNIT 4 PTRP final Convergence in probability.pptx
 
NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024
NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024
NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024
 
21scheme vtu syllabus of visveraya technological university
21scheme vtu syllabus of visveraya technological university21scheme vtu syllabus of visveraya technological university
21scheme vtu syllabus of visveraya technological university
 
Fuzzy logic method-based stress detector with blood pressure and body tempera...
Fuzzy logic method-based stress detector with blood pressure and body tempera...Fuzzy logic method-based stress detector with blood pressure and body tempera...
Fuzzy logic method-based stress detector with blood pressure and body tempera...
 
Filters for Electromagnetic Compatibility Applications
Filters for Electromagnetic Compatibility ApplicationsFilters for Electromagnetic Compatibility Applications
Filters for Electromagnetic Compatibility Applications
 

10401_206296_Hw2

  • 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年第一學期計算機程式語言