Git Product home page Git Product logo

methodsexercise's Introduction

Exercise 1:

Write a C# program that takes user input and creates a story. Ask the user for things like a name, color, an animal, etc. Make up a story and be creative. Hint: Use Console.ReadLine() to take user input and store the input into a variable.

Ask the user β€œWhat is your name?” Store the input.

EXAMPLE:

Console.WriteLine("What is your name?"); // output
var name = Console.ReadLine(); // input

Record user input, for each of these. Combine all answers for a fun, short story.

EXAMPLES:

Name: Michael

Favorite Color: Blue

Favorite Animal: Walrus

Favorite Band: The Beatles

Extra points - turn the answers into a fun short story! Save, commit, and push to Github

Exercise 2:

Write different methods that use each math operator, but allows you to plug in different integers. Calling the different methods would look like:

Sum(2,4) // would return 6
Multiply(10,2) // would return 20 

For Example:

namespace MethodsExercise
{
    internal class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            var name = Console.ReadLine();

            var result = Add(10, 20);
        }

Challenge mode using the params keyword:

Change the functions to use the params keyword to support a range of arguments.

Sum(2,4) would return 6.

Sum(2,4,6) would return 12.

Sum(1,1,1,1,1) would return 5.

  • This way we could plug in multiple different values, and the method we write will still calculate it correctly, we could add, subtract, etc - as many values as we want.

Save, commit, and push to Github

methodsexercise's People

Contributors

acarlson2 avatar schwenk-a avatar mvdoyle avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.