Exercises and solutions for the first day.
Let's display some messages on the console and request the user to enter his name. Output a friendly welcome message with the user's name.
Run this application with the debugger and without the debugger. Can you see any differences? Try setting a breakpoint and play around with the debugger.
Use a for
loop to create a countdown from 10 to 1. Each number should be displayed after a waiting time of 1 second. Realize that waiting period by using Thread.Sleep(1000)
of the System.Threading
namespace.
Write a little currency converter as a console application. The user should be asked to enter a value. Once a value has been entered the user is requested to enter a valid currency exchange rate. Afterwards the converted value should be displayed. Finally, if no error occurred, ask the user if another value should be converted. If yes, then start again by asking the user to enter a value. Otherwise exit the program.
Request the user to enter two numbers and an operation (+
, -
or *
). Use a switch
statement to perform the right computation. Display the result.
The user has to enter some number, which should be evaluated by your program. If the program detects a non-positive, or invalid number, the program should exit. Otherwise the evaluation should display if the entered number has been a prime number or not. In case of not being a prime number, the program has to display all the prime factors of the given number.
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.