|
|
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; } } } | |
|
|
There is no answer at this time. |
|
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. |
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 Home - Answers FAQ - Terms of Service - Privacy Policy |