Advertisement
Guest User

Untitled

a guest
Dec 4th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. Uppgift 6.1
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11. /*
  12. Kurs: 1IK023
  13. Laboration: Lab6.1
  14. Kursdeltagare: Viktor Berggren
  15. Termin och datum: VT16 2016-01-12
  16. */
  17. namespace Laboration_6._1
  18. {
  19. public partial class Form1 : Form
  20. {
  21. int vokal = 0;
  22. int konsonant = 0;
  23. string langtOrd = "";
  24. string kortOrd = "Realisationsvinstbeskattning";
  25.  
  26. public Form1()
  27. {
  28. InitializeComponent();
  29. }
  30. public bool isVowel(char bokstav)
  31. {
  32. string vokaler = "AaEeIiOoUuYyÅåÄäÖö";
  33. for (int i = 0; i < vokaler.Length; i++)
  34. if (bokstav == vokaler[i])
  35. return true;
  36.  
  37. return false;
  38. }
  39. private void laggTillKnapp_Click(object sender, EventArgs e)
  40. {
  41. string ord = indata.Text;
  42.  
  43. if (ord != "stopp")
  44. {
  45. if (ord.Length > langtOrd.Length)
  46. {
  47. langtOrd = ord;
  48. }
  49.  
  50. if (ord.Length < kortOrd.Length)
  51. {
  52. kortOrd = ord;
  53. }
  54.  
  55. for (int i = 0; i < ord.Length; i++)
  56. {
  57. if (isVowel(ord[i]))
  58. vokal++;
  59. else
  60. konsonant++;
  61. }
  62. }
  63. if (indata.Text == "stopp" || indata.Text == "Stopp")
  64. {
  65. utdataVokaler.Text = vokal.ToString();
  66. utdataKonsonanter.Text = konsonant.ToString();
  67. utdataLangsta.Text = langtOrd;
  68. utdataKortaste.Text = kortOrd;
  69. }
  70. indata.Text = "";
  71. }
  72. }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement