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

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter9: Advanced Array Concepts
Section: Chapter Questions
Problem 2PE
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
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,