Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. (Points: 9=3(a)+6(b) ) (a) Prompt user to enter a positive integer number, store this number in variable n (b) Calculate sum from 1 to

image text in transcribed

1. (Points: 9=3(a)+6(b) ) (a) Prompt user to enter a positive integer number, store this number in variable n (b) Calculate sum from 1 to n (that is sum =1+2+3++n ). Display sum. 2. (Points: 25) Prompt user to enter 100 integer numbers. Check and count those numbers which are in the range [1,99]. Meanwhile, sum up all these numbers. After user has entered all numbers, display message: "The sum of all these numbers is { value } " "There are \{value\} numbers in the range [1,99] " The following is a sample output: "The sum of all these numbers is 5678 " "There are 47 numbers in the range [1,99] " 3. (Points: 30) Write a Java program: (30=4(a)+4(b)+4(c)+6(d)+6(e)+6(f)) (a) Define 2 String variables str1 and str2, read 2 text messages from console and assign them to str1 and str2. (b) Display the length of str1 and str2. (c) Display the first character in str1, and the last character in str2 (d) Extract the first word from str1, extract the last word from str2. (e) Compare the first word to the last word extract in (d) to find which word is smaller; display the smaller word first, then display the greater word. (f) Count the occurrence of lowercase letter ' a ' in str1. Display message "\{number\} a are found in the string". (Sample output: "6 a are found in the string")

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Spatial And Temporal Databases 8th International Symposium Sstd 2003 Santorini Island Greece July 2003 Proceedings Lncs 2750

Authors: Thanasis Hadzilacos ,Yannis Manolopoulos ,John F. Roddick ,Yannis Theodoridis

2003rd Edition

3540405356, 978-3540405351

More Books

Students also viewed these Databases questions