Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions Enums/Enum.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using System;

public class Program
{
public static void Main()
{
//Days into Years that Birday occurs
int myBirthday = 9;
//day of week -1 for 1950
int dayOfWeekTracker = -1;
//Enter a year
Console.WriteLine("Enter Year");
//Take input for year.
int year = Convert.ToInt16(Console.ReadLine());

//increments a counter by 1 on normal years and by 2 on leap year to keep track of the week day shift through years
for(int yearCheck = 1950; yearCheck <= year; yearCheck++)
{
//if is a leap year add 2 days.
if(yearCheck % 4 == 0)
{
dayOfWeekTracker += 2;
}
else
//if not leap year add 1.
{
dayOfWeekTracker++;
}
//calculates day of week that birthday lands on.
int DayOfWeek = (myBirthday+dayOfWeekTracker) % 7;
//Writes year and day of the week that birthday lands on.
Console.WriteLine("Year "+ (year)+ " " + (DaysOfWeek)(DayOfWeek));
Console.ReadLine();
}
}
//enum storing the days of the week.
enum DaysOfWeek
{
Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday
}
}
70 changes: 70 additions & 0 deletions Grades/Grades.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
using System;
using System.Linq;
using System.Collections.Generic;
namespace practice_week4
{
class Program
{
static void Main(string[] args)
{
Dictionary<string, List<int>> grades = getStudent();
foreach(var key in grades.Keys)
{
Console.WriteLine("Students Name: " + key);
Console.WriteLine("The Average grade is " + grades [key].Average());
Console.WriteLine("The Minimum grade is " + grades [key].Min());
Console.WriteLine("The Max grade is " + grades [key].Max());
}

}
public static Dictionary<string, List<int>> getStudent()
{
Dictionary<string, List<int>> grades = new Dictionary<string, List<int>>();
//Prompt User to Add names of the Student they want to add.
Console.WriteLine("What is the Students name? ");
string name = Console.ReadLine();
grades.Add(name, getStudentGrade());
Console.WriteLine("Do you want to add another Student?");
string keepAdding = Console.ReadLine().ToLower();


while(keepAdding != "no")
{
Console.WriteLine("What is the students name?");
string newAnswer = Console.ReadLine();
grades.Add(newAnswer, getStudentGrade());
Console.WriteLine("Do you want to add another Student?");
keepAdding = Console.ReadLine();
}
return grades;
}
public static List<int> getStudentGrade()
{

List<int> gradebook = new List<int>();

Console.WriteLine("What is the Students grade?");
int grade = Convert.ToInt32(Console.ReadLine());

gradebook.Add(grade);

Console.WriteLine("Do you want to add another grade?");

string x = Console.ReadLine().ToLower();
while (x != "no")
{

Console.WriteLine("What is the grade");
int numAnswer = Convert.ToInt32(Console.ReadLine());
gradebook.Add(numAnswer);

Console.WriteLine("Add another");
x = Console.ReadLine();

}

return gradebook;

}
}
}
40 changes: 38 additions & 2 deletions Linq/Linq.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,48 @@
using System;
using System.Collections.Generic;
using System.Linq;


namespace Linq
{
class Program
{
static void Main(string[] args)
static void Main()
{
Console.WriteLine("Hello World!");
List<Student> students = new List<Student>();

students.Add(new Student("Chris", "123-456-7891", "123 Delany", -2990));
students.Add(new Student("Terry", "198-765-4321", "321 ynaled", -2500));
students.Add(new Student("Victoria", "512-827-8498", "701 Brazos St", 0));
students.Add(new Student("Luke", "555-555-5555", "451 Brody Ln", -500));
students.Add(new Student("Jessica", "210-895-6658", "578 Blackhill blvd",-3600));

IEnumerable<Student> negativeBalance = from currentStudent in students
where currentStudent.Balance < 0
select currentStudent;

Console.WriteLine("All the students with a negative balance");
foreach(Student currentStudent in negativeBalance)
{
Console.WriteLine(currentStudent.Name);
}

}
}
public class Student
{
public string Name {get; set;}
public string Phone {get; set;}
public string Address {get; set;}
public int Balance {get; set;}

public Student(string name, string phone, string address , int balance)
{

Name = name;
Phone = phone;
Address = address;
Balance = balance;
}
}
}
84 changes: 84 additions & 0 deletions RSP2/RPS2.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
using System;
using System.Collections.Generic;

namespace RockPaperScissors
{
class Program
{
public static void Main()
{
Console.WriteLine("Enter hand 1:");
string hand1 = Console.ReadLine().ToLower();



string hand2;
Random pcturn = new Random();
int answer = pcturn.Next(1,4);

if (answer == 1)
{
hand2 ="rock";
}
else if (answer == 2)
{
hand2 = "paper";
}
else
{
hand2 = "scissors";
}
Console.WriteLine(hand2);

Console.WriteLine(CompareHands(hand1, hand2));

// leave this command at the end so your program does not close automatically
Console.ReadLine();
}
public static string CompareHands(string hand1, string hand2)
{
if (hand1 == hand2)
{
return "It's a tie!";
}

if (hand1 == "rock")
{
if (hand2 == "scissors")
{
return "Hand one wins!";
}
else
{
return "Hand two wins!";
}
}

if (hand1 == "paper")
{
if(hand2 == "rock")
{
return "Hand one wins!";
}
else
{
return "Hand two wins!";
}
}

if (hand1 == "scissors")
{
if(hand2 == "paper")
{
return "Hand one wins!";
}
else
{
return "Hand two wins!";
}

}
return hand1 + ' ' + hand2;
}
}
}