Skip to main content

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...
Submitted byjin29necion Wed, 11/03/2010 - 14:23

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!!!!!!!

it returned the wrong number of consonants 0_0
Submitted byAnonymous (not verified)on Tue, 12/07/2010 - 09:24

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
Submitted bysravani (not verified)on Tue, 02/28/2012 - 16:52

Hello friends ... I need help from you.. regarding a project in c# console applications..

Hi!

you can help me this software:

This software would assist the users to store and retrieve personal information. According to the requirement specifications, the software should provide the functionality to store contact details of various people. It should also enable the user to store the details of meetings and appointments. In addition, the software should display reminders to alert the user for meetings and appointments.

Design specifications

When the application is executed, a menu with the following options should be displayd:
Contact details
Meetings/appointment
On selecting either of the preceding options, a submenu with the following options should be displayed:
Add new record
Delete record
Edit record
Search record
The contact details option would enable the user to add, edit, delete, and search the contact details of various people. the contact include information such as name, address, phone number, and email adress.

Similarly, the Meetings/appointments options enable the user to add, edit, delete, and search meeting/appointment details. The meeting/appointment details include information such as date of meeting/appointment, time, and locationl

note: the address book and the meetings/appointment details should be stored in separate files

When the application is run, reminders for the meetings/appointment scheduled for the current date should be displayed on the screen.

Thanks

Submitted byorchieon Mon, 03/26/2012 - 04:37

Question: A car dealer sells 2 types of cars (Toyota and Honda). He need to keep the following details about the cars he buys: Unique Product Number(e.g 123ABC) , Car Model (e.g Toyota XL 2009), Car Color, Cost Price, Selling Price, and Date Purchased. You are required to create a console application that allows the dealer to input details of cars that he buys. He should also be able to retrieve the details of a particular car by inputting the car’s unique product number. (Hint: Your completed application might run like this.) **Welcome to Car Dealer App** How many cars you want to add : 2 Please type the unique product number: Car Model: Car Color: Cost Price: Selling Price: Date Purchase (M/D/Y): *Press N to add the second car: N Please type the unique product number: Car Model: Car Color: Cost Price: Selling Price: Date Purchase (M/D/Y): *Search for a car >Please type the unique production Number: 123ABC 1 Car found. Model (……), Color(….), Cost Price….. Please i need urgent help on this one Thanks
Submitted bycharies flores (not verified)on Thu, 10/03/2013 - 11:16

please help me understand the codes of the Count of vowels and consonants , what does those numbers 97, 101, 105, 111, 117, 65, 69, 73, 79, 85 do what are they for ? because we were asked to pass a proposed program (which we can refer to the internet) and defend it to our teacher and i found your program interesting and she approved it but i just dont know how to defend it ....please help me for my grades :)

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace ConsoleApplication1
  7. {
  8. class Program
  9. {
  10.  
  11. static void Main(string[] args)
  12. {
  13. string s;
  14. int a1;
  15. int v = 0;
  16. int c = 0;
  17. Console.WriteLine("Enter a string");
  18. s = Console.ReadLine();
  19. a1 = s.Length;
  20. // char[] s1 = new char[a1+1];
  21. char[] s1 = s.ToCharArray();
  22. for (int i = 0; i < a1; i++)
  23. {
  24. if ((s1[i] == 'A') || (s1[i] == 'a') || (s1[i] == 'E') || (s1[i] == 'e') || (s1[i] == 'I') || (s1[i] == 'i') || (s1[i] == 'o') || (s1[i] =='O') || (s1[i] == 'U') || (s1[i] == 'u'))
  25. {
  26. v++;
  27. }
  28. else
  29. {
  30. c++;
  31. }
  32. }
  33. Console.WriteLine("Number of Vowels:" + (v));
  34. Console.WriteLine("Number of Consonants:" + (c));
  35. Console.WriteLine("legth of the sentences:"+a1);
  36. Console.Read();
  37. }
  38.  
  39.  
  40. }
  41. }
Submitted byBijay (not verified)on Wed, 05/14/2014 - 17:40

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Denomination { class Denomination { int counter_500, counter_100, counter_50, counter_20, counter_10, counter_5, counter_2, counter_1; public void CalculateDenomination(int number) { while (number >= 500) { counter_500++; number = number - 500; } while (number >= 100) { counter_100++; number = number - 100; } while (number >= 50) { counter_50++; number = number - 50; } while (number >= 20) { counter_20++; number = number - 20; } while (number >= 10) { counter_10++; number = number - 10; } while (number >= 5) { counter_5++; number = number - 5; } while (number >= 2) { counter_2++; number = number - 2; } while (number >= 1) { counter_1++; number = number - 1; } } public void ShowDenomination() { Console.WriteLine("500 :" + counter_500); Console.WriteLine("100 :" + counter_100); Console.WriteLine("50 :" + counter_50); Console.WriteLine("20 :" + counter_20); Console.WriteLine("10 :" + counter_10); Console.WriteLine("5 :" + counter_5); Console.WriteLine("2 :" + counter_2); Console.WriteLine("1 :" + counter_1); } } class Program { static void Main(string[] args) { Console.WriteLine("Enter amount :"); int number = Convert.ToInt32(Console.ReadLine()); Denomination denomination = new Denomination(); denomination.CalculateDenomination(number); Console.WriteLine("Denomination Result"); denomination.ShowDenomination(); Console.ReadLine(); } } }

Add new comment