Loading

c# console application

3 posts / 0 new
Last post
Offline
Joined: 03/15/2010
c# console application

anyone who can help us in our examination...we are graduating students...
we are asked to the following...

1. Create a C# Console Application program that will accept a whole number as input, and will print the number of each type of denomination it takes to equal the given input. Use the denominations 500, 100, 50, 20, 10, 5, 1.

Example

Enter amount : 137

Denomination Result :
500: 0
100: 1
50: 0
20: 1
10: 1
5: 1
1: 2

2.Create a program that will accept a sentence and count the number of vowels, consonants and determine the length of the sentence. The space is included.

Example

Sentence : The quick brown fox jumps over the lazy dog

Number of Vowels : 11
Number of Consonants : 32
Length of the Sentence : 43

need immediate response for us to be graduated...
thanks a lot...

Offline
Joined: 09/09/2009
problem no.2

it seems no one has ever posted here! i think i might help you! however, if not i hope someone will do
help this post

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace CountOfVowelsAndConsonants
  7. {
  8. class Program
  9. {
  10. static int returnNumberofVowelAllCaps(string strSentence)
  11. {
  12. int intVowel = 0;
  13.  
  14. int[] intVowelCapital = new int[] { 65, 69, 73, 79, 85 };
  15.  
  16. for (int i = 0; i < strSentence.Length; i++)
  17. {
  18. if ((char.IsLetter(strSentence[i])) && (char.IsUpper (strSentence[i])))
  19. {
  20. char character = strSentence[i];
  21.  
  22. if (((int)character >=65) && ((int)character<=90))
  23. {
  24. for (int y = 0; y < intVowelCapital.Length; y++)
  25. {
  26. if ((int)character == intVowelCapital[y])
  27. {
  28. intVowel++;
  29. break;
  30. }
  31. }
  32. }
  33. }
  34. }
  35.  
  36. return intVowel;
  37. }
  38.  
  39. static int returnNumberofVowelSmallCaps(string strSentence)
  40. {
  41. int intVowel = 0;
  42.  
  43. int[] intVowelSmall = new int[] { 97, 101, 105, 111, 117 };
  44.  
  45. for (int i = 0; i < strSentence.Length; i++)
  46. {
  47. if ((char.IsLetter(strSentence[i])) && (char.IsLower(strSentence[i])))
  48. {
  49. char character = strSentence[i];
  50.  
  51. if (((int)character >= 97) && ((int)character <= 122))
  52. {
  53. for (int y = 0; y < intVowelSmall.Length; y++)
  54. {
  55. if ((int)character == intVowelSmall[y])
  56. {
  57. intVowel++;
  58. break;
  59. }
  60. }
  61. }
  62. }
  63. }
  64.  
  65.  
  66. return intVowel;
  67.  
  68. }
  69.  
  70. static int returnNumberofConsonantSmallCaps(string strSentence)
  71. {
  72. int intConsonant = 0;
  73.  
  74. int[] intConsonantSmall = new int[25];
  75.  
  76. int counterr = 0;
  77.  
  78. for (int scon = 97; scon <= 122; scon++)
  79. {
  80. switch (scon)
  81. {
  82. case 97:
  83. case 101:
  84. case 105:
  85. case 111:
  86. case 117:
  87. break;
  88.  
  89. default:
  90. intConsonantSmall[counterr] = scon;
  91. counterr++;
  92. break;
  93. }
  94. }
  95.  
  96. for (int i = 0; i < strSentence.Length; i++)
  97. {
  98. if ((char.IsLetter(strSentence[i])) && (char.IsLower(strSentence[i])))
  99. {
  100. char character = strSentence[i];
  101.  
  102. if (((int)character >= 97) && ((int)character <= 122))
  103. {
  104. for (int intCheckifConsonant = 0; intCheckifConsonant < intConsonantSmall.Length; intCheckifConsonant++)
  105. {
  106. if ((int)character == intConsonantSmall[intCheckifConsonant])
  107. {
  108. intConsonant++;
  109. break;
  110. }
  111. }
  112. }
  113. }
  114. }
  115.  
  116. return intConsonant;
  117. }
  118.  
  119. static int returnNumberofConsonantAllCaps(string strSentence)
  120. {
  121. int intConsonant = 0;
  122.  
  123. int[] intConsonantCaptial = new int[25];
  124.  
  125. int counter = 0;
  126.  
  127. for (int con = 65; con <= 85; con++)
  128. {
  129. switch (con)
  130. {
  131. case 65:
  132. case 69:
  133. case 73:
  134. case 79:
  135. case 85:
  136. break;
  137.  
  138. default:
  139. intConsonantCaptial[counter] = con;
  140. counter++;
  141. break;
  142. }
  143. }
  144.  
  145. for (int i = 0; i < strSentence.Length; i++)
  146. {
  147. if ((char.IsLetter(strSentence[i])) && (char.IsUpper(strSentence[i])))
  148. {
  149. char character = strSentence[i];
  150.  
  151. if (((int)character >= 65) && ((int)character <= 90))
  152. {
  153. for (int intCheckifConsonant = 0; intCheckifConsonant < intConsonantCaptial.Length; intCheckifConsonant++)
  154. {
  155. if ((int)character == intConsonantCaptial[intCheckifConsonant])
  156. {
  157. intConsonant++;
  158. break;
  159. }
  160. }
  161. }
  162. }
  163. }
  164.  
  165. return intConsonant;
  166.  
  167. }
  168.  
  169. static void Main(string[] args)
  170. {
  171. int intVowel =0;
  172.  
  173. int intConsonant =0;
  174.  
  175.  
  176. Console.WriteLine("if first character is lower/upper all characters will in lower/upper case");
  177.  
  178. Console.WriteLine("Please enter a sentence:");
  179.  
  180. string strSentence = Console.ReadLine();
  181.  
  182. if (char.IsUpper(strSentence[0]))
  183. {
  184. strSentence = strSentence.ToUpper();
  185.  
  186. Console.WriteLine("Sentence to be check/evaluated: {0}", strSentence);
  187.  
  188. intVowel = returnNumberofVowelAllCaps(strSentence);
  189.  
  190. intConsonant = returnNumberofConsonantAllCaps(strSentence);
  191. }
  192. else if (char.IsLower(strSentence[0]))
  193. {
  194. strSentence = strSentence.ToLower();
  195.  
  196. Console.WriteLine("Sentence to be check/evaluated: {0}", strSentence);
  197.  
  198. intVowel = returnNumberofVowelSmallCaps(strSentence);
  199.  
  200. intConsonant = returnNumberofConsonantSmallCaps(strSentence);
  201.  
  202. }
  203.  
  204. Console.WriteLine ("Number of Vowels: {0}", intVowel);
  205.  
  206. Console.WriteLine("Number of Consonants: {0}", intConsonant);
  207.  
  208. Console.WriteLine("Number of Length:{0}", strSentence.Length);
  209.  
  210. Console.ReadKey();
  211.  
  212. }
  213. }
  214. }

just trust me on this one it works! thanks!!!!!!!

Anonymous
Please help me

Im a graduating student, please help me.

I was asked to make a system called "sales and reservation system".

I need a code on how the SAVE and DELETE functions work.

or if ever you already have the system, please post the codes here.. thank you all and GodBless

Pages

Add new comment

Filtered HTML

  • You may insert videos with [video:URL]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.