#- why am i getting an error? I’ll add a picture of the error description

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
c#- why am i getting an error? I’ll add a picture of the error description
Week7 CS_WordCounter.Form1
Week7 CS WordCounter
public partial class Forml : Form
{
1 reference
public Form1()
{
: InitializeComponent();
19
20
21
B:
22
23
24
25
2 references
private int Numblords(string words)
{
// splits string when user inputs space
string[] wordCount = Nords.Split(' ');
return wordCount.Length;
26
27
28
29
30
31
32
1 reference
private double AvgCount(string words, int numlords)
{
int numLetters = GetwordCount (words);
double avglordCount = numLetters / numblords;
33
34
35
36
37
38
return avglordCount;
39
2 references
40
private int GetlordCount(string words)
{
string result = "";
foreach (char letter in words)
41
42
43
44
{
if (letter !='')
45
46
result += letter;
47
48
return result.Length;
49
50
51
1 reference
private void button1_Click(object sender, EventArgs e)
52
53
// only counts word and omits whitespace
string words = txtboxlords. Text. Trim();
int wordCount = Numlords (words);
54
55
56
57
double avgCount = AvgCount (words, wordCount);
58
59
MessageBox.Show("There are " + Numllords (words) +" words.", "The are " + GetwordCount(words)+ " letters, ");
60
61
1 reference
private void btnExit_Click(object sender, EventArgs e)
{
this.Close();
62
63
64
65
66
67
68
Transcribed Image Text:Week7 CS_WordCounter.Form1 Week7 CS WordCounter public partial class Forml : Form { 1 reference public Form1() { : InitializeComponent(); 19 20 21 B: 22 23 24 25 2 references private int Numblords(string words) { // splits string when user inputs space string[] wordCount = Nords.Split(' '); return wordCount.Length; 26 27 28 29 30 31 32 1 reference private double AvgCount(string words, int numlords) { int numLetters = GetwordCount (words); double avglordCount = numLetters / numblords; 33 34 35 36 37 38 return avglordCount; 39 2 references 40 private int GetlordCount(string words) { string result = ""; foreach (char letter in words) 41 42 43 44 { if (letter !='') 45 46 result += letter; 47 48 return result.Length; 49 50 51 1 reference private void button1_Click(object sender, EventArgs e) 52 53 // only counts word and omits whitespace string words = txtboxlords. Text. Trim(); int wordCount = Numlords (words); 54 55 56 57 double avgCount = AvgCount (words, wordCount); 58 59 MessageBox.Show("There are " + Numllords (words) +" words.", "The are " + GetwordCount(words)+ " letters, "); 60 61 1 reference private void btnExit_Click(object sender, EventArgs e) { this.Close(); 62 63 64 65 66 67 68
100 %
个-
Error List
Entire Solution
1 Error
Ao Warnings
O of 3 Messages
Build + IntelliSens
Code
Description
CS0161 'Form1.GetWordCount(string)': not all code paths return a value
Error List Data Tools Operations Output
O Ready
Type here to search
Transcribed Image Text:100 % 个- Error List Entire Solution 1 Error Ao Warnings O of 3 Messages Build + IntelliSens Code Description CS0161 'Form1.GetWordCount(string)': not all code paths return a value Error List Data Tools Operations Output O Ready Type here to search
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education