Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Runtime.ExceptionServices;
- using System.Runtime.InteropServices;
- using System.Text;
- using System.Threading.Tasks;
- namespace ControlFlow
- {
- class Program
- {
- static void Main(string[] args)
- {
- //Cwiczenie 1
- //var Excercise1 = new ex1();
- Console.WriteLine("{0}", ex1.mainMethod());
- //Cwiczenie 2
- }
- }
- }
- /*
- Note: For all these exercises, ignore input validation unless otherwise directed. Assume the user enters a value in the format that the program expects.
- For example, if the program expects the user to enter a number, don't worry about validating if the input is a number or not. When testing your program, simply enter a number.
- 1- Write a program to count how many numbers between 1 and 100 are divisible by 3 with no remainder. Display the count on the console.
- 2- Write a program and continuously ask the user to enter a number or "ok" to exit. Calculate the sum of all the previously entered numbers and display it on the console.
- 3- Write a program and ask the user to enter a number. Compute the factorial of the number and print it on the console.
- For example, if the user enters 5, the program should calculate 5 x 4 x 3 x 2 x 1 and display it as 5! = 120.
- 4- Write a program that picks a random number between 1 and 10. Give the user 4 chances to guess the number.
- If the user guesses the number, display “You won"; otherwise, display “You lost". (To make sure the program is behaving correctly, you can display the secret number on the console first.)
- 5- Write a program and ask the user to enter a series of numbers separated by comma. Find the maximum of the numbers and display it on the console.
- For example, if the user enters “5, 3, 8, 1, 4", the program should display 8.
- */
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ControlFlow
- {
- public class ex1
- {
- public static int mainMethod()
- {
- int timesDividable = 0;
- for (int i = 1; i < 101; i++)
- {
- if (i % 3 == 0)
- {
- timesDividable++;
- }
- }
- return timesDividable;
- }
- }
- }
Add Comment
Please, Sign In to add comment