
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
Concept explainers
Question
thumb_up100%
Note:- Please type and execute this java program as soon as possible and also need an output for this java program.
1) This program counts the number of words in a sentence read from the keyboard
Variables:
String str;
char ch;
int x;
int count = 0;
int length;
boolean charBeforeWasPunc = false;
ask the user for a sentence
read the sentence and store it in str
get str length
loop str from x = 0 to length
{
use charAt() and store the xth character in ch
if ch is a punctuation, such as , or . or ; or ! or ‘ ‘(Note that this is a
space char, an empty single quote
increment count
if charBeforeWasPunc is true
{ decerment count
set charBeforeWasPunc to true
}
otherwise set charBeforeWasPunc false
}
if not charBeforeWasPunc is true
increment count
display count
Expert Solution

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

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
- True or False: C++ uses negative values to represent "False" and positive values to represent "True". It is possible that the body of a while loop may not execute at all.arrow_forwardogramming Languages home-335 LAB Mad Lib-loops Mad Libs are activities that have a person provide various words, which are then used to complete a short story in unexpected (and hopefully funny) ways Write a program that takes a string and an integer as input and outputs a sentence using the input values as shown in the example below The program repeats until the input string is quit and disregards the integer input that follows Ex If the input is apples 5 shoes 2 quit o the output is Eating 5 apples a day keeps you happy and healthy. Eating 2 shoes a day keeps you happy and healthy. LAB ACTIVITY B 9 3351 LAB Mad Lib-loops 2 #includearrow_forwardIn Java, If a semicolon is placed at the end of a for statement, the action of the for loop is empty. True or Falsearrow_forward
- Aim: Read a string, S and print its integer value. If S cannot be converted to an integer, print Bad String. ''' # getting the input S = input().strip() try: # if it's possible to convert the entered string into an integer then this block will execute print(int(S)) except: # if it's not possible, then this block will be executed print('Bad String') ''' COMPLEXITY: Time Complexity -> O(1) Space Complexity -> O(1) Sample Input 1: 3 Sample Output 1: 3 Sample Input 2: SB Sample Output 2: Bad String Explaination: '3' as a string can be converted into the integer 3, whereas SB can't be converted to an integer hence the 'except' block is executed and 'Bad String' is printed.arrow_forwardTask 3. Remove white spaces and special symbols Program asks user to input a string to remove white spaces and special symbols (dashes, commas and dots). User inputs a string (with several words) and program prints out the input string without white spaces and special symbols. You may use Scan objects and loops. Example: Input a string to remove special symbols: hey, - i like may. Result: heyilikemayarrow_forwardExercise 1 Backward String Python Pleasearrow_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