-
Notifications
You must be signed in to change notification settings - Fork 0
Checkpoint1 #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Checkpoint1 #6
Changes from all commits
22ccbc6
d8271b9
e112627
2efd24f
ff1c62b
17a8883
125a46f
637fd46
1ed7af7
b53e269
5b13a12
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,116 @@ | ||
| using System; | ||
| using System.Threading; | ||
|
|
||
| namespace Checkpoint1 | ||
| { | ||
| class Program | ||
| { | ||
| static void Main(string[] args) | ||
| static void Main() | ||
| { | ||
| Console.WriteLine("Hello World!"); | ||
| int i; | ||
| //declared the var i to be used in my for loop | ||
| for (i = 1; i <= 100; i++) | ||
| { | ||
| if (i % 3 == 0) | ||
| { | ||
| Console.WriteLine(i); | ||
|
|
||
| } | ||
| } | ||
| Number(); | ||
| Thread.Sleep(2000); | ||
| //wanted the next methods to display on the console using a delay | ||
| Factorial(); | ||
| Thread.Sleep(2000); | ||
| PickNum(); | ||
| Thread.Sleep(2000); | ||
| Max(); | ||
|
|
||
|
|
||
|
|
||
|
|
||
| } | ||
| static void Number() | ||
| { | ||
| int sum = 0; | ||
| while (true) | ||
| { | ||
| Console.Write("Enter a number: or ok to exit : "); | ||
| String input = Console.ReadLine(); | ||
| if (input == "ok" || input.ToLower() == "ok") break; | ||
| if (string.IsNullOrWhiteSpace(input)) | ||
| //i found the class IsNullorWhiteSpace online and thought I should try it out | ||
| continue; | ||
| sum += Convert.ToInt32(input); | ||
| Console.WriteLine(sum); | ||
| } | ||
| Console.WriteLine(sum); | ||
| } | ||
|
|
||
| static void Factorial() | ||
| { | ||
| Console.WriteLine("Please enter your number: "); | ||
| int input = int.Parse(Console.ReadLine()); | ||
|
|
||
| int fact = 1; | ||
| for (int i = 1; i <= input; i++) | ||
| { | ||
| fact *= i; | ||
| } | ||
|
|
||
| Console.WriteLine("The Factorial is " + fact); | ||
| } | ||
|
|
||
| static void PickNum() | ||
| { | ||
| int i; | ||
|
|
||
| for (i = 1; i <=4; i++) | ||
| { | ||
| Console.WriteLine("Pick a random number between 1-10"); | ||
| int number = int.Parse(Console.ReadLine()); | ||
| Random rnd = new Random(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The computer picks a random number for each of my guesses. instead of giving me 4 chances to guess the computer's number. |
||
| int userNum = rnd.Next(1,11); | ||
|
|
||
| if (userNum == number) | ||
| { | ||
| Console.WriteLine("You Won"); | ||
| break; | ||
|
|
||
| } else { | ||
| Console.WriteLine("You Lost"); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought it would give me 4 chances before telling me I lost. |
||
| Console.WriteLine(); | ||
| } | ||
|
|
||
| } | ||
|
|
||
|
|
||
| } | ||
| static void Max() | ||
| { | ||
|
|
||
| Console.Write("Please enter a series of numbers separated by a comma: "); | ||
| string userInput = Console.ReadLine(); | ||
|
|
||
| string[] numbers = userInput.Split(','); | ||
| int max = 0; | ||
| int sum = 0; | ||
|
|
||
| for (int i = 0; i < numbers.GetLength(0); i++) | ||
| { | ||
| if (Convert.ToInt32(numbers[i]) > max) | ||
| { | ||
| max = Convert.ToInt32(numbers[i]); | ||
| // sum = Convert.ToInt32( sum + numbers[i]); | ||
| } | ||
| } | ||
| Console.WriteLine(max + " is the max "); | ||
| // Console.WriteLine(sum + " is the total of all the numbers "); | ||
| Console.ReadLine(); | ||
| } | ||
|
|
||
|
|
||
|
|
||
| } | ||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <OutputType>Exe</OutputType> | ||
| <TargetFramework>netcoreapp2.1</TargetFramework> | ||
| </PropertyGroup> | ||
|
|
||
| </Project> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| using System; | ||
|
|
||
| namespace Week1_Practice | ||
| { | ||
| class Program | ||
| { | ||
| static void Main(string[] args) | ||
| { | ||
| int input1 = 0; | ||
| int input2 = 0; | ||
|
|
||
| Console.WriteLine("Give me a number between 0 and 100:"); | ||
| input1 = Convert.ToInt32(Console.ReadLine()); | ||
| Console.WriteLine("Give me another number between 0 and 100:"); | ||
| input2 = Convert.ToInt32(Console.ReadLine()); | ||
|
|
||
| Console.WriteLine(input1 + input2); | ||
|
|
||
| int yardLength = 0; | ||
| int inchLength = 0; | ||
| Console.WriteLine("Give me a number of yards?"); | ||
| yardLength = Convert.ToInt32(Console.ReadLine()); | ||
| inchLength = (yardLength * 36); | ||
|
|
||
| Console.WriteLine("You have {0} inches!", inchLength); | ||
|
|
||
| bool people = true; | ||
| bool f = false; | ||
| decimal numb = 0.0M; | ||
|
|
||
|
|
||
| string firstName = "DeMarco"; | ||
| string lastName = "Spears"; | ||
| int age = 27; | ||
| string job = "Client Support Agent"; | ||
| string favoriteBand = "Beetles"; | ||
| string favoriteSportsTeam = "Golden State Warriors"; | ||
|
|
||
|
|
||
| Console.WriteLine("Give me a decimal number?"); | ||
| numb = Convert.ToDecimal(Console.ReadLine()); | ||
| Console.WriteLine(numb * numb); | ||
| Console.WriteLine("I love sports my favorite team is the {0}", favoriteSportsTeam); | ||
| Console.WriteLine("My birthday is on the forth of July, I'm {0} years old!", age); | ||
| Console.WriteLine("My favorite band of all time is the {0}!", favoriteBand); | ||
| Console.WriteLine("I work at Dell as a {0}!", job); | ||
|
|
||
| } | ||
| } | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <OutputType>Exe</OutputType> | ||
| <TargetFramework>netcoreapp2.1</TargetFramework> | ||
| <RootNamespace>Week1_Practice</RootNamespace> | ||
| </PropertyGroup> | ||
|
|
||
| </Project> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| using System; | ||
|
|
||
| namespace RockPaperScissors2 | ||
| { | ||
| class Program | ||
| { | ||
| public static void Main() | ||
| { | ||
| try { | ||
|
|
||
| } | ||
| Console.WriteLine("Enter hand 1:"); | ||
| string hand1 = Console.ReadLine().ToLower(); | ||
| Console.WriteLine("Enter hand 2:"); | ||
| string hand2 = Console.ReadLine().ToLower(); | ||
| Console.WriteLine(CompareHands(hand1, hand2)); | ||
|
|
||
| // leave this command at the end so your program does not close automatically | ||
| Console.ReadLine(); | ||
|
|
||
|
|
||
| } | ||
| /// implement exception | ||
| /// catch exception | ||
| // if user enter incorrect imput | ||
|
|
||
| public static string CompareHands(string hand1, string hand2) | ||
| { | ||
| // Your code here | ||
| if (hand1 == "rock" && hand2 == "rock") | ||
| { | ||
| Console.WriteLine("Tie"); | ||
| } else if (hand1 == "rock" && hand2 == "scissors") | ||
| { | ||
| Console.WriteLine("hand1 wins!"); | ||
| } else if (hand1 == "rock" && hand2 == "paper") | ||
| { | ||
| Console.WriteLine("hand2 wins!"); | ||
| } else if (hand1 == "scissors" && hand2 == "rock") | ||
| { | ||
| Console.WriteLine("hand2 wins"); | ||
| } else if (hand1 == "scissors" && hand2 == "paper") | ||
| { | ||
| Console.WriteLine("hand1 wins"); | ||
| } else if (hand1 == "scissors" && hand2 == "scissors") | ||
| { | ||
| Console.WriteLine("Tie"); | ||
| } else if (hand1 == "paper" && hand2 == "paper") | ||
| { | ||
| Console.WriteLine("Tie"); | ||
| } else if (hand1 == "paper" && hand2 == "scissors") | ||
| { | ||
| Console.WriteLine("hand2 wins"); | ||
| } else if (hand1 == "paper" && hand2 == "rock") | ||
| { | ||
| Console.WriteLine("hand1 wins"); | ||
| } else | ||
| { | ||
| Console.WriteLine("try again"); | ||
| } | ||
|
|
||
|
|
||
| return hand1 + ' ' + hand2; | ||
| } | ||
| // public static bool test() | ||
| // { | ||
| // return 0; | ||
|
|
||
| // CompareHands("Paper", "Paper") == 0 && | ||
| // CompareHands("Paper", "Rock") == 1 && | ||
| // CompareHands("Paper", "Scissors") == 2 && | ||
| // CompareHands("Rock", "Paper") == 2 && | ||
| // CompareHands("Rock", "Rock") == 0 && | ||
| // CompareHands("Rock", "Scissors") == 1 && | ||
| // CompareHands("Scissors", "Paper") == 1 && | ||
| // CompareHands("Scissors", "Scissors") == 0 && | ||
| // CompareHands("Scissors", "Rock") == 2; | ||
|
|
||
| // } | ||
| // } | ||
| // } | ||
|
|
||
|
|
||
| // try{ | ||
| // double answer1 = Divide(17.0, 1.0); | ||
| // Console.WriteLine(answer1); | ||
| // } catch (Exception e) { | ||
| // Console.WriteLine("There was a error with the function"); | ||
| // } finally { | ||
| // Console.WriteLine ("Thanks for playing"); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <OutputType>Exe</OutputType> | ||
| <TargetFramework>netcoreapp2.1</TargetFramework> | ||
| <RootNamespace>week4_practice</RootNamespace> | ||
| </PropertyGroup> | ||
|
|
||
| </Project> |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
braces after for the if condition blocks is a good habit to get used to.