Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSC 111 Solving Problems with Computers.

Similar presentations


Presentation on theme: "CSC 111 Solving Problems with Computers."— Presentation transcript:

1 CSC 111

2 Solving Problems with Computers

3 Java Programming: From Problem Analysis to Program Design, Third Edition3 Solving Problems Stages 1.Problem Definition  Define the main Problem

4 Java Programming: From Problem Analysis to Program Design, Third Edition4 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

5 Java Programming: From Problem Analysis to Program Design, Third Edition5 Solving Problems Stages 1.Problem Definition  Define the main Problem 2.Problem Analysis  Determine the inputs, outputs, Arithmetic & logic operations

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

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

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

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

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

11 Java Programming: From Problem Analysis to Program Design, Third Edition11 Algorithms  Write a Program to Print the Sum of two integer Numbers 1.Start the program 2.Read the first number ( N1 ) 3.Read the second number ( N2 ) 4.Sum the both numbers in ( Sum )  Sum = N1 + N2 5.Print the variable ( Sum ) 6.End the program

12 Java Programming: From Problem Analysis to Program Design, Third Edition12 Algorithms  Write a program to Print the Average of three integer numbers 1.Start the program 2.Read the first number ( num1 ) 3.Read the second number ( num2 ) 4.Read the third number ( num3 ) 5.Sum the three numbers in ( result )  result = num1 + num2 + num3

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

14 Java Programming: From Problem Analysis to Program Design, Third Edition14 Algorithms  Write a program to print the volume of a cube and the sum of it’s surfaces’ areas 1.Start the program 2.Read the length of the side ( Length ) 3.Volume = Length * Length * Length 4.Surface = ( Length * Length ) * 6 5.Print the ( Volume ) 6.Print the ( Surface ) 7.End the program

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

16 Java Programming: From Problem Analysis to Program Design, Third Edition16  Sequentially   Conditionally (Selection)   Repetitively

17 Java Programming: From Problem Analysis to Program Design, Third Edition17 Flow Charts

18 Java Programming: From Problem Analysis to Program Design, Third Edition18 Loops Start/End Read/Print Arithmetic Operations Decision Connectors arrows Connectors points Comments Flow chart’s Symbols Start Read n1 N2 = 5 End Print n1 N2 = n1+3 n1 > 3 // my name

19 Simple Sequential Flow Charts start End

20 Java Programming: From Problem Analysis to Program Design, Third Edition20 Write a Program to Print the Sum of two integer Numbers 1.Start the program 2.Read the first number ( N1 ) 3.Read the second number ( N2 ) 4.Sum the both numbers in ( Sum )  Sum = N1 + N2 5.Print the ( Sum ) 6.End the program start Read N1 Read N2 Sum = N1 + N2 Print Sum End

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

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

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

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

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


Download ppt "CSC 111 Solving Problems with Computers."

Similar presentations


Ads by Google