Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program.cs
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Oef3Teldezin
- {
- class Program
- {
- static void Main(string[] args)
- {
- Business z1 = new Business();
- Console.WriteLine("Geef een zin");
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("Aantal woorden in de gegeven zin: " +z1.Aantalwoorden(Console.ReadLine()));
- Console.ReadLine();
- }
- }
- }
- Business.cs
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Oef3Teldezin
- {
- class Business
- {
- public int Aantalwoorden(string pinvoer)
- {
- int aantal = 1;
- for (int teller = 0; teller < pinvoer.Length; teller++)
- {
- if (pinvoer[teller]==' ')
- {
- aantal += 1;
- }
- }
- return aantal;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment