Google Answers Logo
View Question
 
Q: Urgent: program in C# - hints/example given ( No Answer,   1 Comment )
Question  
Subject: Urgent: program in C# - hints/example given
Category: Computers > Programming
Asked by: sean07-ga
List Price: $60.00
Posted: 07 Oct 2004 19:15 PDT
Expires: 08 Oct 2004 16:26 PDT
Question ID: 411819
Develop a library that adds two mixed currencies together and return a
US dollar amount. For example, adds 5 francs and 500 Yen together ( u
can include some other currecies also). The library should handle any
currency as long as the exchange rates are provided. ( you can get
some conversion rates at http://www.exchangerate.com/).
 

--------------------------------------------------------------------------------
Clarification of Question by sean07-ga :

The program should be written in C# in a way that it can be tested using nUnit. 
You also need to write the test cases(as shown below)..without them
this thing will be incomplete. I'm giving an example of the test cases
as well as a program in C# , which can make it much easier for u. The
program checks and accepts only a four leter passwd "TEST". Here it
goes(first see the example of test cases and then the implementation
code...write test cases and implementation code for the given
problem):

Representative tests:
---------------------

using System;
using NUnit.Framework;

namespace Authentication
{
	/*
	 * Class to test Password
	 */
	[TestFixture]
	public class TestPassword
	{
		[Test]
		// Representative Tests For the method verify
		public void testRepVerifyMoreChar()
		{
			Password pw = new Password();
			Assert.IsFalse(pw.verify("TESTTEST"));
		}

		public void testRepVerifyLessChar()
		{
			Password pw = new Password();
			Assert.IsFalse(pw.verify("TES"));
		}
		public void testRepVerifyBlankSpace()
		{
			Password pw = new Password();
			Assert.IsFalse(pw.verify("   "));
		}
		public void testRepVerifyEmptyString()
		{
			Password pw = new Password();
			Assert.IsFalse(pw.verify(""));
		}
		public void testRepVerifyCase()
		{
			Password pw = new Password();
			Assert.IsFalse(pw.verify("test"));
		}
		public void testRepVerifySpecialChar()
		{
			Password pw = new Password();
			Assert.IsFalse(pw.verify("T1#T"));
		}
		public void testRepVerifyNumeric()
		{
			Password pw = new Password();
			Assert.IsFalse(pw.verify("1234"));
		}
		public void testRepVerifyActual()
		{
			Password pw = new Password();
			Assert.IsTrue(pw.verify("TEST"));
		}


Implementation code:
-----------------------
using System;

namespace Authentication
{
	/* 
	 * The class Password, accepts a 4-letter string,
	 * and verifies it with passwd
	 */
	public class Password
	{
		private string passwd = "TEST";
		public bool verify(string s)
		{
			if(s.Length != 4)	return false;

			char[] c = s.ToCharArray();
			foreach(int ch in c)
			{
				if (ch >= 'A' && ch <='Z') 
					continue;
				return false;
			}
			/* 
			 * Implementation for 4c : passes all
			 * representative & exhaustive test cases
			 */
			/*
			char[] pwd = passwd.ToCharArray();
			for(int i=0; i<s.Length; i++)
			{
				if(c[i] != pwd[i])
					return false;
			}
			return true;
			*/

			/* 
			 * Implementation for 4c : passes all
			 * representative but FAILS exhaustive test cases
			 * It fails as the position of each characters are 
			 * not checked. So TETT, SETS .. all are treated as
			 * valid with the following code.
			 */			
			foreach(int ch in c)
			{
				if(passwd.IndexOf((char)ch) < 0) 
					return false;
			}
			return true;
		}
	}
}

Clarification of Question by sean07-ga on 07 Oct 2004 22:24 PDT
I need this today by 2pm EST( abt another 12 hrs since the time the
msg is being posted). Anyone please help.
Answer  
There is no answer at this time.

Comments  
Subject: Re: Urgent: program in C# - hints/example given
From: crythias-ga on 08 Oct 2004 13:19 PDT
 
The answer is convert to dollars each unit, then add dollars to dollars.

Should this be real time or homework?

If it's homework, just get an array of
conversion-to-dollar-from-currency rates, convert each value to
dollars, add the two and get a result.

If it's "real time", then you'll have that list available from a feed.
(www.xe.com has a list of popular conversion rates) Hint: use the
inverse list to multiply to get $.

This is a free comment.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy