Starting from:

$30

Program 1: Lg Lg n

Program 1: Lg Lg n
The purpose of this exercise is to get you started in C# by writing a simple C# program,
compiling and running it, and turning in your source code and executable electronically. Please
use Microsoft Visual Studio under Windows for development. You can do the projects for this
class in the ulab machines booted in Windows. Note that you should save your project on a
network drive, not the C: drive. Microsoft offers a free version of Visual Studio for Windows
online.
Your program should compute floor(lg lg n) without using any special math library functions to
compute lg. It should be a command-shell program like the example below (which uses a rather
poor algorithm to compute the Nth Fibonacci number).
Turn in your program by zipping up your entire project directory and uploading that through the
moodle assignment. Also turn in the program information sheet on the opposite side of this page.
Use good programming style, including comments as needed, consistent indentation, appropriate
variable and function names, good organization, etc.
---------Fib.cs------------
/*********************************************************************
* Simple sample C# selection, showing stdin, stdout, static, cetera
*
* Harry Plantinga, 9/2011
*
*********************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text
namespace Fib
{
 class Program
 {
 static void Main(string[] args)
 {
 Console.WriteLine("Fantastic Fib Finder!");
 while (true)
 {
 Console.Write("\nEnter N: ");
long n = long.Parse(Console.ReadLine());
 long fib = Fib(n);
 Console.WriteLine("Fib({0}) = {1}.", n, fib);
 }
 }
 static long Fib(long n)
 {
 if (n <= 2)
 return 1;
 else
 return Fib(n - 1) + Fib(n - 2);
 }
 }
}
CS212 Program 1 – Grading Sheet
Due date: _____________
Name: _____________________ Section:__ Date turned in: _________ Late? _______
Parts of the program I didn’t get to work:
Comments on this assignment:
______________________________For Grader’s Use________________________________
• Program compiles and runs (50) _____
• Correctly compute floor(log log n) without using library functions (30) _____
• Good programming style including comments as described (10) _____
• Mechanics: turn in program grading sheet; submit electronically (10) _____
Total (100) _____

More products