Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Switch_Statements
- {
- class Program
- {
- static string highScorePlayer = "Steve";
- static int highScore = 999;
- static void Main(string[] args)
- {
- NewScore();
- }
- static void NewScore()
- {
- Console.WriteLine("Enter your score: ");
- string playerScore = Console.ReadLine();
- if(int.TryParse(playerScore,out int Score))
- {
- if (Score > highScore)
- {
- Console.WriteLine("Enter your name: ");
- string playerName = Console.ReadLine();
- Console.WriteLine("New highscore is " +
- "" + Score);
- Console.WriteLine("New highscore holder is " + playerName);
- }
- else
- {
- Console.WriteLine("The old highscore of " + highScore + " could not be broken and is still held by " +highScorePlayer);
- }
- }
- else
- {
- Console.WriteLine("Enter a numeric value.");
- }
- Console.ReadKey();
- }
- }
- }
- /*/
- int age = 25;
- switch (age)
- {
- case 15:
- Console.WriteLine("too young to enter!");
- break;
- case 25:
- Console.WriteLine("enter for free!!!");
- break;
- case 40:
- Console.WriteLine("too old");
- break;
- default:
- Console.WriteLine("how old are u then?");
- break;
- }
- /*/
- /*/
- Console.WriteLine("Enter your age:");
- string age = Console.ReadLine();
- if (int.TryParse(age, out int ageInt))
- {
- if (ageInt == 25)
- {
- Console.WriteLine("You can enter for free");
- }
- else if (ageInt<20 || ageInt>29)
- {
- Console.WriteLine("You can't enter this place");
- }
- else
- {
- Console.WriteLine("How old are you?");
- }
- }
- else
- {
- Console.WriteLine("Enter number value.");
- }
- /*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement