
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
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](https://content.bartleby.com/qna-images/question/92ccc3b3-aa75-41cd-a4b9-e3917fd50498/aa4a8aa2-2c5e-473e-bfdd-796c6e336a57/n2hxwt_thumbnail.jpeg)
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

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

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 2 steps

Knowledge Booster
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
- Write a C# program that plays a guessing game with the user. Your program should select a random number between 1 and 50 and then let the user try to guess it. The program should continue asking the user for a number until he guesses correctly. (See below for some tips on random numbers). CHALLENGE #1: Modify your program so that it only allows the user 10 guesses, and then declares them to be an inadequate guesser if they haven’t gotten it correct. Your program should output the random number chosen. CHALLENGE #2: Modify your program so that after they guess a number (or get declared inadequate, if you do Challenge #1) that it asks them if they want to play again, and responds accordingly. Some Random Number Generation HintsRandom rndNumber = new Random();Console.WriteLine(rndNumber.Next()); //random integerConsole.WriteLine(rndNumber.Next(101)); //random integer between 0 and 100Console.WriteLine(rndNumber.Next(10, 43)); //random integer between 10 and…arrow_forwardDiscussion: chapter 4 Pick a method of debugging/error catching and explain how it works and give a real world example of how it works.arrow_forwardJAVASCRIPT SOLUTION PLEASE You are going to be given a word. Your job is to return the middle character of the word. If the word's length is odd, return the middle character. If the word's length is even, return the middle 2 characters.arrow_forward
- CODE IN C# NOT JAVA (reject if you can't do C# please): Write an application that runs 1,000,000 games of craps and answers the following questions (explain each step): How many games are won on the first roll, second roll, …, twentieth roll and after the twentieth roll? How many games are lost on the first roll, second roll, …, twentieth roll and after the twentieth roll? What are the chances of winning at craps? [Note: You should discover that craps is one of the fairest casino games. What do you suppose this means?] What is the average length of a game of craps?arrow_forwardJava - Data Visualization (this is not graded)arrow_forwardInstructor note: Important Coding Guidelines: Use comments, and whitespaces around operators and assignments. Use line breaks and indent your code. Use naming conventions for variables, functions, methods, and more. This makes it easier to understand the code. Write simple code and do not over complicate the logic. Code exhibits simplicity when it’s well organized, logically minimal, and easily readable. A pedometer treats walking 1 step as walking 2.5 feet. Define a method named feetToSteps that takes a double as a parameter, representing the number of feet walked, and returns an integer that represents the number of steps walked. Then, write a main program that reads the number of feet walked as an input, calls method feetToSteps() with the input as an argument, and outputs the number of steps. Use floating-point arithmetic to perform the conversion. Ex: If the input is: 150.5 the output is: 60 The program must define and call a method:public static int feetToSteps(double…arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

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)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education