100% Guaranteed Results


Advance Csharp – Exercise: Methods Solved
$ 29.99
Category:

Description

5/5 – (1 vote)

Problem 1. Letter Creator
Write a program that creates a letter. It takes as input the sender and the receiver and prints a formatted output on the console.
This is a sample way of defining the method.

static means that you do not need an instance of your class to use its methods. You will learn about classes in the next course
void means that the method will return nothing. Since we only print to the console, there is no need to return anything.
string sender, string receiver, and DateTime currentTime are the input parameters of the method. There can be as many as you like and any type you need.

Test your program with the following input. Find the way to format the time as in the output shown below.
Input Output
Gosho
Pesho Dear Gosho,
I hope I find you in good health.
I need to inform you that the cheese has run away.
Sincerely, Pesho
9/14/2015
Problem 2. Uppercase Chars at Even Positions
Write a program that takes an input in the form of a string and transforms each of its characters at even position to its uppercase representation. Note that the string indexation is zero-based (of course, we are programmers) and the number zero is even.

Let’s continue with the method logic. Strings in C# are immutable so you cannot directly modify their characters. One of the handy ways to deal with this is to create an array that holds the characters. Arrays are mutable so you won’t have any problems modifying them. Search the web how you can uppercase a single character

Notice the return statement. We cannot directly return the array because our program expects a string. We can use the string constructor. It has an option to pass it an array of characters, and it creates a string out of them.
Test your program with the following input. If you like, you can think of other strings to test.
Input Output
Byrzo che sireneto izbega!
ByRzO ChE SiReNeTo iZbEgA!

Reviews

There are no reviews yet.

Be the first to review “Advance Csharp – Exercise: Methods Solved”

Your email address will not be published. Required fields are marked *

Related products