King Fahd University of Petroleum Minerals College of

  • Slides: 9
Download presentation
King Fahd University of Petroleum & Minerals College of Computer Science & Engineering Information

King Fahd University of Petroleum & Minerals College of Computer Science & Engineering Information & Computer Science Department ICS 102: Introduction To Computing Problem Solving 2 1

Problem Solving Techniques • You follow algorithms every day in your life. So, we

Problem Solving Techniques • You follow algorithms every day in your life. So, we need to learn how to design algorithms not simply follow them. • So, what is Problem Solving Process? 1. Analysis 2. Design 3. Implementation 4. Testing Some Strategies to solve problems • Ask questions • Look for things that are familiar • Means-Ends Analysis • Divide and Conquer. 2

Replace a Word Write a program that reads a line of text and then

Replace a Word Write a program that reads a line of text and then outputs that line of text with the first occurrence of “hate” changed to “like”. You can assume that the word “hate” occurs in the input. If the word “hate” occurs more than once in the line, your program will replace only the first occurrence. 3

Multi-way if statement Write a multi-way if-else statement that evaluates a student academic performance

Multi-way if statement Write a multi-way if-else statement that evaluates a student academic performance on the following criteria: • A GPA 3. 0, output Honor • A GPA 2. 0, output Good Standing • A GPA < 2. 0 and 1. 5, output Poor • A GPA < 1. 5, output Very Poor 4

Salesman Commission • A salesperson is given commission on the following basis: • Write

Salesman Commission • A salesperson is given commission on the following basis: • Write a program which reads SALES and prints the corresponding commission. 5

Leap Year Design and implement a program that reads a four digit integer representing

Leap Year Design and implement a program that reads a four digit integer representing a year, then it determines whether the year is a leap year or not. Display the year that you entered and a message indicating whether it is leap or not. A year is leap if: • it is divisible by 4 and not by 100, or • it is divisible by 400. 6

Averaging a List of Scores Design and implement a program that prompts the user

Averaging a List of Scores Design and implement a program that prompts the user to enter a set of scores, then computes and displays the average, min , and max score. 7

Sum of Even and Odd Integers Design and implement a program that computes the

Sum of Even and Odd Integers Design and implement a program that computes the sum of the even numbers and the sum of odd numbers between 1 and 100. 8

Sum of Digits Design and implement a program that prompts its user for a

Sum of Digits Design and implement a program that prompts its user for a nonnegative integer value n, assume that n has 4 digits or less. The program then computes and displays the sum of digits in n. For example, if n is 1234, the output should be: Sum of digits in 1234 is: 10 9