Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Daniboi

Member
  • Content Count

    28
  • Joined

  • Last visited

Awards


This user doesn't have any awards

About Daniboi

  • Title
    Member

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. so i was told sbyte and this is only a very small bit of my code
  2. ah no so they actually told me to it this way
  3. hi, yeah so i am trying to make sure that it stays within range of those numbers like the flowchart seen bellow
  4. Hi, i have wrote a piece of code however i cant remember how you get some data validation in. i want my numbers to stay within -10 and +10 and it should the display "invalid answer" and then ignore that user input however it just says in valid answer. bool bUserInput; sbyte sbNumber; if (sbNumber < -11 || sbNumber > 11) { //the error message Console.WriteLine("Your are out of range please stay between -10 and +10"); bUserInput = false; }
  5. hi i am still learning c# and i am developing a peice of code that will average the users input. i am struggling however witth keeping the user input under or equal to 100. { int[] array1 = new int[15]; Console.WriteLine("please give me 15 numbers and i will give you the average of them"); for (int i = 0; i < array1.Length; i++) { while (int.TryParse(Console.ReadLine(), out array1[i]) == false) { Console.WriteLine("Please give me a number not text"); } } //here the averaging takes place it basscially averages the array that it has and here it joins all the array inputs together with a + sign Console.WriteLine("The average is {0} / 15 = {1}", string.Join("+", array1), array1.Average()); }
  6. ok thnks that will really help
  7. yeah so the reason for sbyte is so i can go into negitive numbers. my issue is that i know the theory but not well enough to code. this assignment is just a relitivity annoying one. i just am stuck on what part you have to do get a user input
  8. so i am trying to make a program that asks for a user input between -10 and +10 and then adds them together. i am really new to c# and would really appricate some help with it and so far its gone as well as a drunk doctor tying to do heart surgry. here is what i have wrote but i have no clue what to do next nor get the bit i have done to work. Thanks sbyte sbnum1 = 0; sbyte sbnum2 = 0; sbyte.TryParse(Console.ReadLine(); sbyte answer = sbnum1 + sbnum2;
  9. Daniboi

    C# help?

    { class Program { static void Main(string[] args) { string userChoice; Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine(" Please pick an option between 1 and 5"); Console.WriteLine("\n1.Tell me 10 names and i will say them back"); Console.WriteLine("\n2.average of 5 numbers"); Console.WriteLine("\n3.Ask the user for a number and tell them whether it is an even number or an odd number"); Console.WriteLine("\n4.Welcomes you to the system"); Console.WriteLine("\nQuit is 0"); userChoice = Console.ReadLine(); switch (Console.ReadKey().KeyChar) { case '1': Console.Clear(); NameRepeat(); break; case '2': Console.Clear(); AverageOfFive(); break; case '3': Console.Clear(); OddOrEven(); break; case '4': Console.Clear(); Welcome(); break; case '0': Console.Clear(); Quit(); break; } //1 void NameRepeat() { string[] array1 = new string[10]; for (int i = 0; i < 10; i++) { Console.WriteLine("please give me 10 names and i will repeat them to you"); Console.ReadLine(); Console.Write("The name of the person is :" + i); } } //4 void Welcome() { string myName = ""; Console.Write("Please enter your name: "); myName = Console.ReadLine(); Console.Write("Welcome to the sytem: " + myName); } //3 void OddOrEven() { Console.WriteLine(int.Parse(Console.ReadLine()) % 2 == 0 ? "even" : "odd"); } //0 void Quit() { Environment.Exit(0); } //2 void AverageOfFive() { string[] cijfers = new string[10] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" }; int i = 0; int sum = 0; for (i = 0; i < 5; i++) { Console.Write("The average is: {0}", sum / 5); } } } } }
  10. Daniboi

    C# help?

    yeah it yeah i did and the same thing happens.
  11. Daniboi

    C# help?

    yeah that didnt work . could you explain for me in very simple terms what i have done wrong (i am a bit of a dummie)
  12. Daniboi

    C# help?

    Thanks ill see what happens
  13. Daniboi

    C# help?

    i am trying to complete the task: 1) Create a program that has a menu with 5 options: Option 1 - Ask the user for 10 first names and then output them in the format: User #1 is <Name>> User #2 is <<Name>> etc Option 2-Ask for 5 numbers and calculate the average Option 3-Ask the user for a number and tell them whether it is an even number or an odd number Option 4 - Ask for someone's name and then display 'Welcome to the system <<Name>> Option 5=Exit the program however it locked on the first option and doesnt do any others.
×