Questions
-
Write method signatures for:
- a method that takes one integer parameter
- a method that returns a Boolean value
- a method that takes one double and one string parameter and returns an integer value
- a method that takes one integer reference parameter and returns a boolean value
- Draw a hierarchy chart for the completed calculator program
- What is meant by the term structured programming?
- Explain how the two methods below can each use a variable named
x
.
-
What might be considered wrong with the following method?
Additional Exercises
- Create a method GetMax() with two integer (int) parameters, that returns the larger of the two numbers. Write a program that reads three numbers from the console and prints the biggest of them. Use the GetMax() method you just created.
- Write a method that finds how many times a certain number can be found in a given array. Write a program to test that the method works correctly.
- Write a program that calculates and prints the n! for any n in the range \(1\) .. \(100\).
-
Write a program to convert a \(8\)-bit binary number into its denary equivalent. Decompose the program into several methods e.g. InputBinaryValue(), ConvertBit(), OutputResult(). Use the following pseudocode:
- Test your program with the following values: (a) 10000000; (b) 11111111; (c) 10010011
- Adapt the program so it can work with any length of binary number
-
Write a program that solves the following tasks:
-
Put the digits from an integer number into a reversed order.
- Calculate the average of given sequence of numbers.
- Solve the linear equation a * x + b = 0.
Create appropriate methods for each of the above tasks. Make the program show a text menu to the user. By choosing an option of that menu, the user will be able to choose which task to be invoked