Question: Problem 1: Read an integer number from the user. If the number is not positive, change its sign. Create the algorithms for the following tasks:

 Problem 1: Read an integer number from the user. If the

number is not positive, change its sign. Create the algorithms for the

following tasks: 1 2 Count the digits of the number Count the

odd digits of the number Calculate the sum of the digit values

of the number 3 Problem 2: Using the knowledge acquired in Unit

Problem 1: Read an integer number from the user. If the number is not positive, change its sign. Create the algorithms for the following tasks: 1 2 Count the digits of the number Count the odd digits of the number Calculate the sum of the digit values of the number 3 Problem 2: Using the knowledge acquired in Unit 1, regarding Binary numbers, create an algorithm that reads a 4-bit binary number from the keyboard as a string and then converts it into a decimal number. For example, if the input is 1100, the output should be 12. (Hint: Break the string into substrings and then convert each substring to a value for a single bit. If the bits are bo, bs, b2, and b3, the decimal equivalent is 8bo+ 4b1+ 2b2+ b3.) Problem 4: Imagine yourself in the middle of Manhattan, where the streets are perpendicular on avenues. You are in a grid of streets, somewhat lost, and you randomly pick one of four directions and walk to the next intersection. Not knowing where you really want to go, you again randomly pick one of the four directions, and so on. After repeating the same movement for a number of times, you may want to know how far you got from the original point. Represent locations as integer pairs(x,y). Create an algorithm that implements your movement through New York City, over 100 intersections, starting at (0,0) and print the ending location, taking into consideration that each movement, from one intersection to another will be one mile. Problem 5: Design an algorithm that, given two strings of characters, tests whether the first string appears as a substring somewhere in the second. Problem 3: Suppose you attend a party. To be sociable, you will shake hands with everyone else. Write the algorithm that will compute the total number of handshakes that occur. (Hint: Upon arrival, each person shakes hands with everyone who is already there. Use the loop to find the total number of handshakes as each person arrives.)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!