1 / 24

Solving Problems with Computers

Solving Problems with Computers. Solving Problems Stages. Problem Definition Define the main Problem. Problem Definition. Write a Program to Print the Sum of two integer Numbers Write a program to Print the Average of three integer numbers

Télécharger la présentation

Solving Problems with Computers

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Solving Problems with Computers

  2. Solving Problems Stages • Problem Definition • Define the main Problem Java Programming: From Problem Analysis to Program Design, Third Edition

  3. Problem Definition • Write a Program to Print the Sum of two integer Numbers • Write a program to Print the Average of three integer numbers • Write a program to print the volume of a cube and the sum of it’s surfaces’ areas Java Programming: From Problem Analysis to Program Design, Third Edition

  4. Solving Problems Stages • Problem Definition • Define the main Problem • Problem Analysis • Determine the inputs, outputs, Arithmetic & logic operations Java Programming: From Problem Analysis to Program Design, Third Edition

  5. Problem Analysis • Write a Program to Print the Sum of two integer Numbers Inputs : • First Number • Second Number Operations : • Summation = first + second Output : • The summation Java Programming: From Problem Analysis to Program Design, Third Edition

  6. Problem Analysis • Write a program to Print the Average of three integer numbers Inputs : • First Number • Second Number • Third Number Operations : • Average = (first + second + third ) / 3 Output : • The Average Java Programming: From Problem Analysis to Program Design, Third Edition

  7. Problem Analysis • Write a program to print the volume of a cube and the sum of it’s surfaces’ areas Inputs : • Side Length Operations : • Volume = side * side * side • Surface area = ( side * side ) * 6 Output : • The Volume • The surface area Java Programming: From Problem Analysis to Program Design, Third Edition

  8. Solving Problems Stages Problem Definition Algorithm Problem Analysis Solution Design Design a solution for the problem by writing an algorithm or drawing a flow chart Flow Chart Java Programming: From Problem Analysis to Program Design, Third Edition

  9. Basic steps for designing a solution Read all the inputs Calculate operations Print the output Java Programming: From Problem Analysis to Program Design, Third Edition

  10. Algorithms • Write a Program to Print the Sum of two integer Numbers • Start the program • Read the first number ( N1 ) • Read the second number ( N2 ) • Sum the both numbers in ( Sum )  Sum = N1 + N2 • Print the variable ( Sum ) • End the program Java Programming: From Problem Analysis to Program Design, Third Edition

  11. Algorithms • Write a program to Print the Average of three integer numbers • Start the program • Read the first number ( num1 ) • Read the second number ( num2 ) • Read the third number ( num3 ) • Sum the three numbers in ( result )  result = num1 + num2 + num3 Java Programming: From Problem Analysis to Program Design, Third Edition

  12. Algorithms • Write a program to Print the Average of three integer numbers • Divide the ( result ) by 3 and save the result in ( Average )  Average = result / 3 • Print the ( Average ) • End the program Java Programming: From Problem Analysis to Program Design, Third Edition

  13. Algorithms • Write a program to print the volume of a cube and the sum of it’s surfaces’ areas • Start the program • Read the length of the side ( Length ) • Volume = Length * Length * Length • Surface = ( Length * Length ) * 6 • Print the ( Volume ) • Print the ( Surface ) • End the program Java Programming: From Problem Analysis to Program Design, Third Edition

  14. Organization of Instructions • Instructions that describe behavior can be organized in three ways in most programming languages: • Sequentially • Conditionally (Selection) • Repetitively Java Programming: From Problem Analysis to Program Design, Third Edition

  15. Conditionally (Selection) • Sequentially • Repetitively Java Programming: From Problem Analysis to Program Design, Third Edition

  16. Flow Charts Java Programming: From Problem Analysis to Program Design, Third Edition

  17. Flow chart’s Symbols End Start Print n1 Read n1 N2 = n1+3 N2 = 5 n1 > 3

  18. start Simple Sequential Flow Charts End

  19. Write a Program to Print the Sum of two integer Numbers start • Start the program • Read the first number ( N1 ) • Read the second number ( N2 ) • Sum the both numbers in ( Sum )  Sum = N1 + N2 • Print the ( Sum ) • End the program Read N1 Read N2 Sum = N1 + N2 Print Sum End Java Programming: From Problem Analysis to Program Design, Third Edition

  20. Write a program to print the volume of a cube and the sum of it’s surfaces’ areas start Read L • Start the program • Read the length of the side ( Length ) • Volume = Length * Length * Length • Surface = ( Length * Length ) * 6 • Print the ( Volume ) • Print the ( Surface ) • End the program Volume = L * L * L ٍSurface = ( L * L ) * 6 Print Volume Print Surface End Java Programming: From Problem Analysis to Program Design, Third Edition

  21. Write a program to Print the Average of three integer numbers start or Read num1 start Read num2 Read num1,num2,num3 Read num3 result = num1+num2+num3 result = num1+num2+num3 Average = result/3 Average = result/3 Print Average Print Average End End Java Programming: From Problem Analysis to Program Design, Third Edition

  22. Write a program to Print the Average of three integer numbers or start Read num1,num2,num3 Average = ( num1+num2+num3 ) / 3 Print Average End Java Programming: From Problem Analysis to Program Design, Third Edition

  23. Write a program to Print the Average of three integer numbers start start result =num1+num2+num3 Read num3 Read num1 Read num1 Read num2 Read num2 result =num1+num2+num3 Read num3 Average = result/3 Average = result/3 Print Average Print Average End End Java Programming: From Problem Analysis to Program Design, Third Edition

  24. Write a program to Print the Average of three integer numbers start start Read num1, num2,num3 Read num1, num2,num3 result = num1+num2+num3 Average =result/3 Average = result/3 result= num1+num2+num3 Print result Print Average Print result End End Java Programming: From Problem Analysis to Program Design, Third Edition

More Related