SlideShare una empresa de Scribd logo
1 de 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年第一學期計算機程式語言

Más contenido relacionado

La actualidad más candente (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 a 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 a 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
 

Más de 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補充教學
 

Último

Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Christo Ananth
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
ankushspencer015
 

Último (20)

Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and Properties
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICSUNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
UNIT-IFLUID PROPERTIES & FLOW CHARACTERISTICS
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
Vivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design SpainVivazz, Mieres Social Housing Design Spain
Vivazz, Mieres Social Housing Design Spain
 

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