Chapter 1.2: C# Intro

3 Days in a Row, Let’s Go!

using System;
namespace Challenge{
class Program{
static void Main(string[] args){
// prompt for and get angle
Console.Write("Enter angle in degrees: ");
float angle = float.Parse(Console.ReadLine());
// calculate and print cosine and sine
angle *= (float)Math.PI / 180;
Console.WriteLine("Cosine: " + Math.Cos(angle));
Console.WriteLine("Sine: " + Math.Sin(angle));
Console.WriteLine();
}}}

This challenge requires designing a console app that can take user input and respond with the appropriate output (and also some Math, no pun intended). The System namespace has the Console.ReadLine() function for doing just this. Finally, need to use the Math library to use PI.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Abish Pius

Data Science Professional who teaches with unflashy, simple to understand python code.