Question
C# 1, This method will display (with Console.Write*) a solid rectangle of fillCharacter whose number of rows and number of columns are specified in the
C#
1, This method will display (with Console.Write*) a solid rectangle of fillCharacter whose number of rows and number of columns are specified in the arguments as row and column, respectively.
public void DisplayBox(int row, int column, char fillCharacter){
}
2, Write code segments that accomplish each cof the following tasks. Do not use string operations. (a) Calcualte the integer part of the quotient when integer a is divided by integer b. (b) Calculate the integer remainder when integer a is divided by integer b. (c) Use the app pieces developed in parts (a) and (b) to add a body into this method that receives an integer and displays it as a sequence of digits, separating each pair of digits by two spaces. Example: SeparateDigit(4562) should display 4 5 6 2.
public void DisplayDigits(int n) {
3, The Power function takes a decimal number and an integer. It then computes a to the n power. Note that if n is 0, their power is 1. If n is a negative number, the result is 1 over the power with a positive value of n. Assume that a cannot be 0. There are a few ways to write this method. The simplest way is to use a loop. The other way is to write in recursion. The third way is to use a smarter loop with bitwise operations. Do not use built-in functions such as Math.Pow(). For example, Power(3, 4) calculates 3*3*3*3 The last assertion will require you to do a quicker way either with bit shifting or recursion because you will need to multiply to one billion times to approximate an e.
public decimal Power(decimal a, int n) {
4, Return the smallest of the three integers. Do not use built-in functions.
public decimal Minimum3(int a, int b, int c) {
5, An integer number is said to be prime if it's greater than 1 and divisible by only 1 and itself. Write a method that determines whether a number is prime or not. For example, 2, 3, 5, 7 are prime but 4, 6, 8, 9 are not. (b) Initially, you might think that n/2 is the upper limit for which you must test to see whether a number is prime, but you need to go only as high as the square root of n.
6, An integer number is said to be a perfect number if its factors, including 1 (but not the number itself), sum up to the number. For example, 6 is a perfect number, because 6 = 1+ 2 + 3. Write a method that determines whether parameter value is a perfect number.
public bool PerfectNumber(int number) {
7, The greatest common divisor (GCD) of two integers is the largest integer that evenly divides each of the two numbers.
public int Gcd(int a, int b) {
8, The least common multiple is the smallest integer that is divisible by both a and b.
public long Lcm(int a, int b) {
9, Write a method that takes an non-negative integer value and returns the string in ones and zeros with its bits reversed. Do not use any built-in function but bitwise shift. Also, do not prepend the zeros to your bits. For example, a reverse bit for 8 is "1" because 8 representing 1000 in binary reverses to "0001", which is essentially "1". A string representation that contains 0's and 1's. 123 is written in 1111011 in binary, so its reversed bits is 1101111.
public string ReverseBits(int n) {
10, This function returns the GPA on a scale of 4 for the points, which is between 0% and 100%. In addition, this method also outputs the letter grade as the out letterGrade. 0-59: F (GPA=0), 60-63: D- (GPA=2/3), 64-66: D (GPA=1), 67-69: D+ (GPA=4/3), 70-73: C- (GPA=5/3), 74-76: C (GPA=2), 77-79 C+ (GPA=7/3), 80-83: B- (GPA=8/3), 84-86: B (GPA=3), 87-89 B+ (GPA=10/3), 90-93: A- (GPA=11/3), 94-96: A (GPA=4). A scale between 0 and 100. This is the second output that outputs the letter grade. Try to see any pattern here to avoid a bunch of if-statements.
public decimal Gpa(int points, out string letterGrade) {
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started